Microsoft KB Archive/65822

How to Use the DDERequest Statement in Word for Windows

PSS ID Number: Q65822 Article last modified on 02-17-1993

1.00 1.10 WINDOWS

Summary: DDERequest allows Word for Windows to access a string variable at a specific location designated in a DDE (Dynamic Data Exchange). The location must first be established with a DDEInitiate statement. For more information, query on the following words: how and use and DDEInitiate and Statement and Word and Windows

More Information: The syntax for the DDERequest statement is A$ = DDERequest$(ChanNum, Item$ ) where A$ is a string variable to which the requested information will be assigned. ChanNum is the variable for the DDE channel number that is created with the DDEInitiate statement. Item$ is a string variable containing the server applications location of the requested data, such as “R1C1” for Excel or a defined field like “NAME” in Superbase 4 Windows. Special items are available in most DDE aware applications. If used in conjunction with the “SYSTEM” topic, these items can provide useful information such as a list of currently open documents or the Clipboard formats that the application supports. These items are as follows:

The following are examples of how to use the DDERequest statement in Word for Windows to Excel and Superbase 4 Windows:

Superbase 4 Windows
In the following routine, the text between <> should appear as one line without the <> symbols:  Sub MAIN REM Loads Superbase minimized if not already loaded If isapploaded("SB4W") = 0 Then Shell("SB4W", 0) REM Initiates DDE link ChanNum1 = DDEInitiate("SB4W", "TEST.SBF") REM Gets value of NAME field in Superbase FirstName$ = DDERequest$(ChanNum1, “NAME”) REM Terminates all DDE links DDETerminateAll End Sub

Excel
In the following routine, the text between <> should appear as one line without the <> symbols:  Sub MAIN REM Loads Excel minimized if not already loaded If isapploaded("EXCEL") = 0 Then Shell("EXCEL", 0) REM Initiates DDE link ChanNum1 = DDEInitiate("EXCEL", "TEST.XLS") REM Gets value of R1C1 in Excel FirstName$ = DDERequest$(ChanNum1, “R1C1”) REM Terminates all DDE links DDETerminateAll End Sub For more information on DDE and Word for Windows, see pages 31-32 of TECHREF.DOC, or pages 21-24 of the “Microsoft Word for Windows Technical Reference.”

Reference(s): “Microsoft Word for Windows and OS/2 Technical Reference,” page 148. Microsoft Press, 1990.

Additional reference words: w4wmacro