ID: Q112044
The information in this article applies to:
- Standard and Professional Editions of Microsoft Visual Basic for
Windows, version 3.0
- Microsoft Word for Windows, version 6.0
This article shows by example how to make a Visual Basic program display Microsoft Word version 6.0 toolbars. It is not possible to display the toolbars using the OLE control alone, so the following example uses an OLE object in combination with the OLE control.
When editing a Microsoft Word document that is in an OLE control, you may find it helpful to use the Microsoft Word toolbars. However, if you close all your toolbars, there is no way to use the OLE control alone to get the toolbars back. The following example shows how to access the Word toolbars after closing them.
1. Start Visual Basic or from the File menu, choose New Project (ALT, F, N)
if Visual Basic is already running. Form1 is created by default.
2. Add an MSOLE2 control (OLE1) to Form1. When the Insert Object dialog box
asks what type of object to insert, choose the Create From File option.
and select a Microsoft Word .DOC file.
3. Set the SizeMode property of the OLE1 control to 1 (Stretch).
4. Add a command button (Command1) to Form1.
5. Add the following code to the click event of the Command1 button:
Sub Command1_Click()
Dim wbObject As Object
ole1.Action = 7
Set wbObject = CreateObject("Word.basic")
wbObject.ViewToolbars "Standard", , , , , , , 1
End Sub
6. Run the program.
7. Double-click the OLE1 control. If you see the toolbars, close them and
press the ESC key to return control to Visual Basic. Double-click the
OLE1 control again. This time the toolbars are gone. Now click the
Command1 button to bring up the Standard toolbar. To bring up any of
the other toolbars from this point, move the mouse pointer over the
Standard toolbar. Then click the right mouse button, and choose the
toolbar you want.
Additional query words:
Keywords : kbAutomation kbCtrl kbVBp300 kbWord
Last Reviewed: January 6, 1999