Microsoft KB Archive/58904

Using DDE Macro to Send Commands from WinWord to Excel

PSS ID Number: Q58904 Article last modified on 06- 9-1992

1.00 1.10 1.10a 2.00 2.00a WINDOWS

Summary: The example below is a macro for Microsoft Word for Windows that sends commands to Microsoft Excel for Windows using dynamic data exchange (DDE). This macro makes the following assumptions: - The worksheet “SHEET1.XLS” exists and is located in the C: directory. - There is a cell on this worksheet that was previously named “test” using the Formula Define Name command.

Example
In the following routine, the text between the single angle brackets should appear as one line without the single angle brackets.   SUB MAIN  IF IsAppLoaded("EXCEL") = 0 THEN SHELL "EXCEL.EXE"  ExecuteString$  = “=B1{enter}” ChanNum = DDEInitiate(“EXCEL”, “C:1.XLS”)  DDEExecute ChanNum, ExecuteString$ DDEExecute ChanNum, “[App.Minimize]” DDETerminate ChanNum END SUB Running this macro places the formula “=B1” in the cell named “test.”

Additional reference words: w4wmacro 1.0 1.1 1.1a 2.0 2.0a 1.00 1.10 1.10a 2.00 2.00a