Article ID: 161621
Article Last Modified on 10/11/2006
Type CommandBarType
NameOfCommandBar As String
IsVisible As Boolean
Value As Byte
End Type
Sub MakeBarVisible()
' Holds command bar information. This is a user-defined datatype
' defined in the Declarations section.
Dim UsedBarList() As CommandBarType
' Stores the prompt in the message box.
Dim message As String
' Controls For loop.
Dim i As Byte
' Counts the visible command bars.
Dim CountVisible As Byte
' Stores the return value of the message box.
Dim result As Integer
' Initialize CountVisible.
CountVisible = 0
' Get space in the array for the standard command bar.
ReDim Preserve UsedBarList(0)
' Store the settings for the standard command bar.
With UsedBarList(0)
.IsVisible = Application.CommandBars(3).Visible
.NameOfCommandBar = Application.CommandBars(3).Name
.Value = 3
End With
' Get space in the array for the Formatting command bar.
ReDim Preserve UsedBarList(1)
' Store the settings for the Formatting command bar.
With UsedBarList(1)
.IsVisible = Application.CommandBars(4).Visible
.NameOfCommandBar = Application.CommandBars(4).Name
.Value = 4
End With
' Get space in the array for the drawing command bar.
ReDim Preserve UsedBarList(2)
' Store the settings for the Drawing command bar.
With UsedBarList(2)
.IsVisible = Application.CommandBars(8).Visible
.NameOfCommandBar = Application.CommandBars(8).Name
.Value = 8
End With
' Build the prompt for the message box.
message = "Would you like me to turn ON the following"
message = message & " command bar(s)?" & Chr(13)
' Loop through the three command bars and see whether visible.
For i = 0 To 2
' See whether the command bar is not visible.
If UsedBarList(i).IsVisible = False Then
' Add a space and a tab and the name of command bar.
message = message & Chr(13) & Chr(9)
message = message & UsedBarList(i).NameOfCommandBar
CountVisible = CountVisible + 1
End If
Next i
' See whether the three command bars are visible.
If CountVisible = 0 Then
' The three command bars are visible.
MsgBox "The Standard, Formatting, and Drawing command " _
& " bars are already visible. Disable one or more and run " _
& "the macro again.", vbInformation
End
End If
' Display the message box.
result = MsgBox(message, vbQuestion + vbYesNo)
' Check which button was selected in the message box.
If result = vbNo Then
End
End If
' Turn on the command bars.
For i = 0 To 2
' See whether the command bar is not visible.
If UsedBarList(i).IsVisible = False Then
' Make the command bar visible.
With Application.CommandBars(UsedBarList(i).Value)
.Visible = True
End With
End If
Next i
End Sub
176476 OFF: Office Assistant Not Answering Visual Basic Questions
163435 VBA: Programming Resources for Visual Basic for Applications
Additional query words: 97 8.00 kbmacro ppt8 vba vbe commandbar macppt mac_ppt ppt98 98 powerpt toolbar tool bars bar menus menu office
Keywords: kbcode kbdtacode kbhowto kbmacro kbprogramming KB161621