OFF98: Visible Property Does Not Apply to All CommandBars (182345)
The information in this article applies to:
- Microsoft Excel 98 Macintosh Edition
- Microsoft Word 98 Macintosh Edition
- Microsoft PowerPoint 98 Macintosh Edition
- Microsoft Visual Basic for Applications 5.0
This article was previously published under Q182345 SYMPTOMS
In the programs listed at the beginning of this article, when you attempt
to hide or display a command bar in a Visual Basic for Applications Sub
procedure, you may receive an error message that is similar to the
following:
Run-time error '-2147483640 (80000008)':
Method 'Visible' of object 'CommandBar' failed
CAUSE
This problem occurs when you attempt to hide or display a command bar that
does not support the Visible property.
WORKAROUNDMicrosoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.
To work around this behavior, determine whether the command bar supports
the Visible property before you set the property to True.
The following example loops through all of the command bars and determines
if each command bar supports the Visible property. If the command bar
supports the property, the property is set to True without generating the
error message mentioned in this article.
On Error Resume Next
For Each ComBar In Application.CommandBars
' To display the command bar names, use the following line.
' MsgBox ComBar.Name
ComBar.Visible = True
Next ComBar
End Sub
NOTE: In the example, an On Error statement is inserted before the For Each
loop. If you run the macro without the On Error statement, you receive the
error message mentioned in this article.
REFERENCES
For more information about command bars, click the Office Assistant while
in the Visual Basic Editor, type commandbars, click Search, and then
click to view "Using command bars."
NOTE: If the Assistant is hidden, click the Office Assistant button on the
Standard toolbar.
Modification Type: | Minor | Last Reviewed: | 10/11/2006 |
---|
Keywords: | kbprb kbProgramming KB182345 |
---|
|