Excel Macro to Determine If Word for Windows Is Loaded

Last reviewed: February 5, 1998
Article ID: 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 operating system versions 3.0 and 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("KERNEL","GetModuleHandle","IC") =CALL(A2,"winword.exe") =IF(A3<>0) =ALERT("Word is already running") =ELSE() =EXEC("winword.exe") =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("C:\winword\winword.exe")

REFERENCES

"Microsoft Excel Function Reference," version 4.0, page 138.


KBCategory: kbmacro
KBSubcategory:
Additional query words: winword2 2.0 2.0a 2.0b isapploaded running
word6 exec shell winword
Keywords : kbinterop kbmacro
Version : 2.0 2.0a 2.0a-CD 2.0b 2.0c
Platform : WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 5, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.