How to Use DDEExecute from Word for Windows to ExcelLast reviewed: November 4, 1994Article ID: Q58367 |
The information in this article applies to:
SUMMARYThe following is a macro for Word for Windows that sends commands to Microsoft Excel by way of dynamic data exchange (DDE). This macro makes the following assumptions:
MORE INFORMATIONThe Microsoft Word for Windows macro code is as follows:
Declare Function IsAppLoaded Lib "kernel"(name$) As Integer Alias"GetModuleHandle"
Sub MAINIf IsAppLoaded ("EXCEL") = 0 Then Shell "EXCEL.EXE" ExecuteString$ = "=B1{enter}" ChanNum = DDEInitiate("EXCEL", "C:\WINDOWS\SHEET1.XLS") DDEExecute ChanNum, "[App.Restore()][Formula.Goto( " + Chr$(34) + "test" + Chr$(34) + ")]" DDEExecute ChanNum, ExecuteString$DDEExecute ChanNum, "[App.Minimize()]" DDETerminate ChanNum End SubWhen run, this macro checks to see if Microsoft Excel is already running. If it isn't, it starts Microsoft Excel. If it is not known what sheet(s) are currently open when Microsoft Excel is loaded, use "system" as the second parameter of the DDEInitate() command. You can then issue a Microsoft Excel OPEN() command using DDEExecute to open a specific file. Also, the Formula.Goto() statement in the above DDEExecute statement is the equivalent of the following Microsoft Excel macro statement:
=FORMULA.GOTO("test") |
KBCategory: kbinterop
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |