Microsoft KB Archive/222784

= PPT2000: Sample Visual Basic Code to Manipulate Command Bars =

Article ID: 222784

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft PowerPoint 2000 Standard Edition

-



This article was previously published under Q222784





SUMMARY
This article contains a sample Microsoft Visual Basic for Applications macro (Sub procedure) that enables the Standard, Formatting, or Drawing command bars if they are not visible.



MORE INFORMATION
Microsoft 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. NOTE: The following macro examples work only in PowerPoint. Visual Basic for Applications macros are not supported by the Microsoft PowerPoint Viewer. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

Sample Visual Basic Procedure
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

