0
我为插件创建了一个代码,其中我的所有代码在单击一个按钮后一次运行。但是现在我想创建一个下拉列表,我可以选择任何一个事件来运行。如何在PowerPoint 2007中使用VBA在插件中创建下拉列表?
下面是我对按钮的代码:
Sub Auto_Open()
Dim oToolbar As CommandBar
Dim oButton As CommandBarButton
Dim MyToolbar As String
' Give the toolbar a name
MyToolbar = "Test"
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 = "Test_dist"
'Tooltip text when mouse if placed over button
.Caption = "Trial"
'Text if Text in Icon is chosen
.OnAction = "TEST"
'Runs the Sub Button1() code when clicked
.Style = msoButtonIconAndWrapCaptionBelow
' Button displays as icon, not text or both
.FaceId = 1885
.TooltipText = "Test your presentation"
End With
' You can set the toolbar position and visibility here if you like
' By default, it'll be visible when created
oToolbar.Top = 50
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
Resume NormalExit:
End Sub
感谢史蒂夫Rindsberg – 2012-02-23 11:42:49