ID: Q69675
The information in this article applies to:
When declaring an external function that takes an integer as one of its parameters in a Word for Windows version 1.1 macro, "As Integer" must be used specifically in the parameter declaration or an Unrecoverable Application Error (UAE) will occur.
If the Declare statement made a call to IsAppLoaded using "(name$)" instead of "(name$) As Integer," a UAE will occur in Word for Windows when the macro is run.
In word for windows version 7.0 most function calls now return a 32 bit result refered to as a long. In function declarations As Long must be inserted in place of As Integer or a worbasic error 100 (Syntax error ) will result.
This procedure is different in Word for Windows version 2.0. If "As Integer" is not specified, you will receive a WordBASIC error 100, "Syntax Error".
WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this macro code "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.
Windows Dynamic Link Libraries (DLL) can be accessed using WordBasic macros in Word for Windows. In the following example, an external function is declared for use within Word for Windows using the WordBasic macro language.
For example:
Declare Function GetModuleHandle Lib "kernel32" Alias
"GetModuleHandleA"(lpModuleName$) As Long
Sub Main
lpModuleName$ = InputBox$("Enter an application name")
If GetModuleHandle(lpModuleName$) > 0 Then MsgBox "The application is _
loaded "
End Sub
Declare Function IsAppLoaded Lib "kernel" (name$) As Integer
Alias "GetModuleHandle"
Sub Main
AppName$ = InputBox$("Enter an application name (e.g., Excel)")
If IsAppLoaded(AppName$) Then Print "The application is loaded"
End Sub
"Microsoft Word for Windows and OS/2 Technical Reference," pages 437-438
"Word95 developer's kit, Win32api.txt"
Kbcategory: kbusage kbmacro KBSubcategory: Additional query words: 2.0 2.0 6.0 6.0a 6.0c winword2 winword word7 winword 6.0a 6.0c 7.0 word95 word6 word6 word97 word8 8.0
Version : 1.x 2.x 6.0 6.0a 6.0c 7.0 7.
Platform : WINDOWS
Last Reviewed: July 30, 1997