I created one code for addin in which my all code runs at one time after clicking of one button. But now I want to create dropdown list in which I can select any one event for run.
Below is my code for button:
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
Try this:
And this to handle the change event of the dropdown: