Microsoft KB Archive/161621

From BetaArchive Wiki

Article ID: 161621

Article Last Modified on 10/11/2006



APPLIES TO

  • Microsoft PowerPoint 98 for Macintosh
  • Microsoft PowerPoint 97 Standard Edition



This article was previously published under Q161621

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.

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 creating Visual Basic for Applications macros, click the Office Assistant in Microsoft PowerPoint, type how to create a macro, click Search, and then click to view "Create a macro in Visual Basic Editor."

For more information about running Visual Basic for Applications macros, click the Office Assistant in Microsoft PowerPoint, type how to run a macro, click Search, and then click to view "Run a macro."

NOTE: If the Assistant is hidden, click the Office Assistant button on the Standard toolbar. If the Assistant is not able to answer your query, please see the following article in the Microsoft Knowledge Base:

176476 OFF: Office Assistant Not Answering Visual Basic Questions


For more information about getting help with Visual Basic for Applications, please see the following article in the Microsoft Knowledge Base:

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