Displaying a Word or Custom Dialog Using OLE AutomationLast reviewed: February 6, 1998Article ID: Q108686 |
The information in this article applies to:
SUMMARYYou cannot directly define and display a Microsoft Word 6.0 dialog box through OLE Automation. However, you can run a WordBasic macro that displays a dialog box. To display a Word dialog or user-defined dialog when using OLE Automation, activate Word for Windows and then run a WordBasic macro that includes the dialog statements.
WordBasic ToolsMacro Parameter SyntaxToolsMacro [.Name = text], [.Run], [.Edit], [.Show = number], [.Delete], [.Rename], [.Description = text], [.NewName = text], [.SetDesc]
ExamplesThe following Visual Basic procedure activates Word for Windows and runs a global macro named "test".
Sub Command1_Click ()Dim wordobj As Object Set wordobj = CreateObject("Word.Basic") If wordobj.DocMaximize() = True Then AppActivate "Microsoft Word - " + wordobj.[WindowName$]()Else AppActivate "Microsoft Word"End If wordobj.ToolsMacro "test", True, , 1 End SubNOTE: Word needs to have the focus (AppActivate) prior to running the global "test" macro. The "test" macro can be used to display a Word dialog or a user-defined dialog. The following WordBasic macros serve as examples of each. REM WordBasic macro named "Test" REM This macro displays Word's FileSaveAs dialog Sub MAINDim dlg As FileSaveAs GetCurValues dlg n = Dialog(dlg) If n = - 1 Then FileSaveAs dlg End SubREM WordBasic macro named "Test" REM This macro displays a user-defined dialog. Sub MAINBegin Dialog UserDialog 320, 144, "Microsoft Word" OKButton 210, 76, 88, 21 TextBox 29, 38, 160, 18, .TextBox1 CancelButton 212, 101, 88, 21 Text 29, 21, 35, 13, "Text", .Text1End Dialog Dim dlg As UserDialog n = Dialog(dlg) End SubWARNING: 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.
REFERENCES"Microsoft Word Developer's Kit," version 6.0, Microsoft Press, 1993, pages 179-180
|
KBCategory: kbmacro
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |