Must Specify as Integer When Calling External DLL

ID: Q69675


The information in this article applies to:
  • Microsoft Word for Windows, versions 1.0, 1.1, 1.1a, 2.0, 2.0a, 2.0a-CD, 2.0b, 2.0c, 6.0, 6.0a, 6.0c
  • Microsoft Word for Windows 95, versions 7.0, 7.0a
  • Microsoft Word 97 for Windows


SUMMARY

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.

Word 7.0, 97

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.

Word 2.0, 6.0

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".


MORE INFORMATION

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:

Word 7.0, 97


   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 

Word 2.x, 6.x


   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 


REFERENCES

"Microsoft Word for Windows and OS/2 Technical Reference," pages 437-438

"Word95 developer's kit, Win32api.txt"

Additional query words: 2.0 6.0 winword2 winword word7 7.0 word95 word6 word97 word8 8.0

Keywords :
Version : WINDOWS:1.0,1.1,1.1a,2.0,2.0a,2.0a-CD,2.0b,2.0c,6.0,6.0a,6.0c,7.0,7.0a
Platform : WINDOWS
Issue type :


Last Reviewed: November 3, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.