BUG: No Toolbars Displayed When Word Doc Activated from a VB OLE Container

ID: Q176244


The information in this article applies to:


SYMPTOMS

When you activate an OLE container as a Word Document object from within Microsoft Visual Basic, the Toolbars command on the View menu shows Standard, Formatting, and other toolbars selected. However, no toolbars display. The following sample code makes all selected toolbars visible within an OLE container created in Microsoft Visual Basic.

NOTE: This example assumes you have already created a form in Microsoft Visual Basic and:

For the purposes of this example, place the following code within the Click event procedure of the command button:

   Private Sub Command1_Click()

      Dim tbar As Object
      Dim iPrevBarPos As Integer

      OLE1.Action = 7

      ' Starts in-place activation for the object within the OLE container.
      Set tBar = OLE1.object

      ' Loop through each command bar to determine its visible attribute.
      For Each cBAr In tBar.CommandBars

         ' If the command bar should be visible...
         If cBar.Visible Then

            ' Make the command bar visible.
            ' NOTE: The Position property only works with the
            ' msoBarFloating constant in Visual Basic using in-place
            ' activation. All the other toolbar constants
            ' (msoBarTop, msoBarBottom, and so on) will not display the
            ' toolbar. Because of this, the toolbars cannot be docked
            ' within the OLE container.
            cBar.Position = msoBarFloating

            ' Sets the height of the specified command bar in pixels.
            cBar.Height = 25

            ' Sets the distance (in pixels) from the top edge of the
            ' specified command bar to the top edge of the screen.
            cBar.Top = iPrevBarPos + cBar.Height

            ' Get the top position of this bar to apply to height of next
            ' bar, so the command bars are stacked and not layered.
            iPrevBarPos = cBar.Top

            ' Sets the distance (in pixels) from the left edge of the
            ' specified command bar to the left edge of the screen.
            cBar.Left = 1

         End If

      Next

   End Sub 


STATUS


REFERENCES

For more information about getting help with Visual Basic for Applications, please see the following article in the Microsoft Knowledge Base:

Q163435 VBA: Programming Resources for Visual Basic for Applications

Additional query words: wordcon vba word8 word97 word9 word2000

Keywords : kbcode kbprg kbwordvba KbVBA kbDSupport
Version : WINDOWS:2000,97
Platform :
Issue type : kbbug
Technology : kbWordSearch kbWordWSearch


Last Reviewed: October 17, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.