Macro to Test Whether Windows Application Is Loaded

Last reviewed: July 14, 1995
Article ID: Q59296
The information in this article applies to:
  • Microsoft Excel for Windows, versions 2.x, 3.0, 4.0, 5.0

SUMMARY

The following command macro tests to see if a Windows application is currently loaded without activating the application.

The macro code is as follows, starting in cell A1 of the macro sheet:

   A1: IsAppLoaded
   A2: =REGISTER("KERNEL","GetModuleHandle","IC")
   A3: =CALL(A2,B1)
   A4: =RETURN()

In this example, the name of the application being referenced is kept as text in cell B1. If the application is loaded, a nonzero value is returned in cell A3. If the application is not loaded, A3 contains 0 (zero).

Note that the application name in cell B1 should be in the form of the name of the application executable without the .EXE or .COM extension. For example, the correct text to test for Microsoft Word for Windows is "WINWORD" (without the quotation marks).

Note: the information above also applies to version 5.0 only when using version 4.0 macro language.


KBCategory: kbusage
KBSubcategory:

Additional reference words: 2.0 2.00 2.01 2.1 2.10 3.0 3.00 4.0 4.00
5.0 5.00 check running



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: July 14, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.