PPT2000: Sample Visual Basic Code to Manipulate Command Bars
ID: Q222784
|
The information in this article applies to:
-
Microsoft PowerPoint 2000
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, including, but not limited to, the
implied warranties of merchantability and/or fitness for a particular
purpose. This article assumes that you are familiar with the programming
language being demonstrated and the tools used to create and debug
procedures. Microsoft Support professionals 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
needs. If you have limited programming experience, you may want to contact
the Microsoft fee-based consulting line at (800) 936-5200. For more
information about the support options available from Microsoft, please see
the following page on the World Wide Web:
http://www.microsoft.com/support/supportnet/overview/overview.asp
NOTE: The following macro examples only work from within the PowerPoint application. Visual Basic for Applications macros are not supported by the Microsoft PowerPoint Viewer. For additional information, please see the following article in the Microsoft Knowledge Base:
Q230746 PPT: Viewer: Presentation Macros Don't Run
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
REFERENCES
For more information about using the sample code in this article, please
see the following article in the Microsoft Knowledge Base:
Q212536
OFF2000: How to Run Sample Code from Knowledge Base Articles
Additional query words:
9.00 ppt9 vba vbe ppt2k powerpt vba2k ppt9.0 ppt2000 program programming toolbar tool bars bar menus menu office
Keywords : kbcode kbmacro kbprg kbdta kbdtacode kbpptvba
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbhowto