How to View Microsoft Word Toolbars Using OLE Control

Last reviewed: June 21, 1995
Article 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

SUMMARY

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.

MORE INFORMATION

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.

Step-by-Step Example

  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 reference words: 3.00
KBCategory: kbole kbprg kbcode
KBSubcategory: IAPOLE PrgCtrlsCus


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 21, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.