The information in this article applies to:
In Microsoft Excel, you can write a macro that will open and close Microsoft Word for Windows from Microsoft Excel. To create this macro, do the following:
Sample Macro 1The following sample Microsoft Excel macro, starts Word for Windows, initiates a DDE channel using the topic "System," and terminates the open channel number:A1: =EXEC("winword") A2: =INITIATE("winword","system") A3: =EXECUTE(A2,"[FileExit(1)]") A4: =TERMINATE(A2) A5: =RETURN() NOTE: This macro assumes that Word for Windows is in your path. Sample Macro 2The following Microsoft Excel macro, initiates a DDE Channel to Microsoft Word for Windows. In addition, it checks to see if Word for Windows is currently running. If it is, the macro initiates the channel to the current session of Word. This eliminates the problem of multiple instances of Word for Windows being opened unnecessarily. If Word for Windows is not running the macro starts Word.A1: =SET.NAME("HANDLE",REGISTER("kernel","getModuleHandle","IC")) A2: =SET.NAME("CALLVALUE",CALL(Handle,"WINWORD.EXE")) A3: =IF(CallValue=0) A4: =EXEC("WINWORD.EXE") A5: =END.IF() A6: =INITIATE("WINWORD","SYSTEM") A7: =RETURN() Note: this is also true for Microsoft Excel version 5.0 macro sheets when you use version 4.0 macros. REFERENCES
"Function Reference," version 4.0, pages 240-241 Additional query words: 2.0 2.00 2.01 2.1 2.10
Keywords : |
Last Reviewed: March 21, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |