Excel Macro to Determine If Word for Windows Is Loaded

ID: Q94624

The information in this article applies to:

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

Last Reviewed: February 5, 1998