Displaying a Word or Custom Dialog Using OLE Automation |
Q108686
You 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.
ToolsMacro [.Name = text], [.Run], [.Edit], [.Show = number],
[.Delete], [.Rename], [.Description = text], [.NewName = text],
[.SetDesc]
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 Sub
NOTE: Word needs to have the focus (AppActivate) prior to running the
global "test" macro.
Sub MAIN
Dim dlg As FileSaveAs
GetCurValues dlg
n = Dialog(dlg)
If n = - 1 Then FileSaveAs dlg
End Sub
REM WordBasic macro named "Test"
Sub MAIN
Begin 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", .Text1
End Dialog
Dim dlg As UserDialog
n = Dialog(dlg)
End Sub
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.
"Microsoft Word Developer's Kit," version 6.0, Microsoft Press, 1993, pages 179-180
Additional query words: 6.0 visual basic appactivate word6 7.0 word95 word7 winword user defined
Keywords : kbole
Issue type :
Technology :
|
Last Reviewed: November 4, 2000 © 2001 Microsoft Corporation. All rights reserved. Terms of Use. |