Using Windows Calls to Create Dialog Boxes in Word for Windows

ID: Q80931

The information in this article applies to:

SUMMARY

In Microsoft Word for Windows macros, you can use Microsoft Windows calls to create dialog boxes.

MORE INFORMATION

The following is a sample Word for Windows macro that uses Windows calls to display a sample dialog box:

Word 7.0

Declare Function GetFocus Lib "user32" Alias "GetFocus"() As Long
Declare Function MessageBox Lib "user32" Alias "MessageBoxA"(hWndParent \
As Long, lpText As String, lpCaption As String, wType As Long) As Long

Sub MAIN
hWndParent = GetFocus lpText$ = "Example Text" lpCaption$ = "Example Caption" wType = 0 result = MessageBox(hWndParent, lpText$, lpCaption$, wType)
End Sub

Word 6.0, 2.0

Declare Function GetFocus Lib "user"() As Integer
Declare Function MessageBox Lib "user"(hWndParent As Integer, lpText$, \
lpCaption$, wType As Integer) As Integer
Sub MAIN
hWndParent = GetFocus lpText$ = "Example Text" lpCaption$ = "Example Caption" wType = 0 result = MessageBox(hWndParent, lpText$, lpCaption$, wType)
End Sub

For more information on creating dialog boxes using the WordBasic macro language, query on the following in the Microsoft Knowledge Base:

   dialog and box and macro and editor

REFERENCES

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

"Using WordBasic," by WexTech Systems and Microsoft, pages 173, 363-366

Kbcategory: kbusage kbmacro KBSubcategory: Additional query words: winword2 6.0 6.0a 6.0c winword 7.0 word95 word7 word6 1.0 1.10 1.10a 2.0

Version           : 1.x 2.x 6.0 6.0a 6.0c 7.0
Platform          : WINDOWS

Last Reviewed: July 30, 1997