Microsoft KB Archive/94624

{|
 * width="100%"|

Excel Macro to Determine If Word for Windows Is Loaded

 * }

Q94624

-

The information in this article applies to:


 * Microsoft Word for Windows, versions 2.0, 2.0a, 2.0a-CD, 2.0b, 2.0c, 6.0, 6.0a, 6.0c
 * Microsoft Windows versions 3.0, 3.1

-

SUMMARY
The Microsoft Excel EXEC function can be used within an Excel macro to launch Word for Windows. However, if Word for Windows is already running, the EXEC function might launch another instance of Word for Windows (multiple instances of Word for Windows version 2.0 are possible if SHARE.EXE is loaded).

MORE INFORMATION
The following Excel macro tests whether Word for Windows is currently running before using the EXEC function. The macro code begins in cell A1 of the macro sheet:

IsAppLoaded =REGISTER(&quot;KERNEL&quot;,&quot;GetModuleHandle&quot;,&quot;IC&quot;) =CALL(A2,&quot;winword.exe&quot;) =IF(A3<>0) =ALERT(&quot;Word is already running&quot;) =ELSE =EXEC(&quot;winword.exe&quot;) =END.IF =RETURN Instead of the ALERT function, you can use DDE commands to begin and maintain a DDE conversation with Word for Windows. If the Word for Windows program directory is not on the MS-DOS path, indicate the full path to the Word for Windows executable. For example:

"=EXEC(&quot;C:\winword\winword.exe&quot;)"