BUG: No Toolbars Displayed When Word Doc Activated from a VB OLE Container
ID: Q176244
|
The information in this article applies to:
-
Microsoft Word 97 for Windows
-
Microsoft Word 2000
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:
- the form contains an OLE container that has its Class property set to a
Word Document object (Word.Document.8). For Word 2000, the Class property is set to Word.Document.9,
-and-
- the form contains a command button,
-and-
- a reference to the Microsoft Office 8.0 Object Library has been set. With Office 2000, set a reference to Microsoft Office 9.0 Object Library.
Follow these steps to add the Microsoft Office 8.0 or 9.0 Object Library
reference:
- On the Project menu, click References.
- Under Available References, click to select the Microsoft Office
8.0 Object Library, or the Microsoft Office 9.0 Object Library for Office 2000 check box.
- Click OK.
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 : WINDOWS
Issue type : kbbug