如何在Power Point 2007中添加“添加”菜单选项卡?

时间:2013-08-28 11:46:21

标签: powerpoint

我正在使用Power Point 2007,但没有Add Ins菜单选项卡,我找不到如何添加它。

1 个答案:

答案 0 :(得分:0)

当PPT 2007及其后续版本运行代码时,会创建" legacy"命令栏或菜单修改,它会自动将加载项选项卡添加到功能区,并将命令栏/菜单更改放在那里。这是一些简单的示例代码。您可以按原样运行它,也可以将其另存为加载项。加载加载项后,每次PPT启动时都会运行Auto_Open代码。

Sub Auto_Open()
    Dim oToolbar As CommandBar
    Dim oButton As CommandBarButton
    Dim MyToolbar As String

    ' Give the toolbar a name
    MyToolbar = "Kewl Tools"

    On Error Resume Next   
    ' so that it doesn't stop on the next line if the toolbar's already there

    ' Create the toolbar; PowerPoint will error if it already exists
    Set oToolbar = CommandBars.Add(Name:=MyToolbar, _
        Position:=msoBarFloating, Temporary:=True)
    If Err.Number <> 0 Then  
          ' The toolbar's already there, so we have nothing to do
          Exit Sub
    End If

    On Error GoTo ErrorHandler

    ' Now add a button to the new toolbar
    Set oButton = oToolbar.Controls.Add(Type:=msoControlButton)

    ' And set some of the button's properties

    With oButton

         .DescriptionText = "This is my first button"   
          'Tooltip text when mouse if placed over button

         .Caption = "Do Button1 Stuff"    
         'Text if Text in Icon is chosen

         .OnAction = "Button1"  
          'Runs the Sub Button1() code when clicked

         .Style = msoButtonIcon    
          ' Button displays as icon, not text or both

         .FaceId = 52       
          ' chooses icon #52 from the available Office icons

    End With

    ' Repeat the above for as many more buttons as you need to add
    ' Be sure to change the .OnAction property at least for each new button

    ' You can set the toolbar position and visibility here if you like
    ' By default, it'll be visible when created. Position will be ignored in PPT 2007 and later
    oToolbar.Top = 150
    oToolbar.Left = 150
    oToolbar.Visible = True

NormalExit:
    Exit Sub   ' so it doesn't go on to run the errorhandler code

ErrorHandler:
     'Just in case there is an error
     MsgBox Err.Number & vbCrLf & Err.Description
     Resume NormalExit:
End Sub

Sub Button1()
' This code will run when you click Button 1 added above
' Add a similar subroutine for each additional button you create on the toolbar
    ' This is just some silly example code.  
    ' You'd put your real working code here to do whatever
    ' it is that you want to do
    MsgBox "Stop poking the pig!"
End Sub