Ronnie
Ronnie

Reputation: 11198

Execute menu commands in powerpoint

I have a custom plugin that was made for powerpoint and has a functionality to export the current slide as HTML5. It doesn't support exporting the entire PPT so basically I would have to go slide by slide and export.

My question is, can I write something in VB that can execute a menu command, finish, next slide, execute menu command etc?

I don't even know if VB would be the correct language to use. I've never written anything in it.

Upvotes: 0

Views: 1611

Answers (1)

Steve Rindsberg
Steve Rindsberg

Reputation: 3528

VBA might be simpler since it's built into PowerPoint.

If you know the name of the command bar and the control on the command bar that you want to launch:

Sub LaunchTheCommand()
    Dim oCmdbar As CommandBar
    Set oCmdbar = Application.CommandBars("CommandBarName")
    oCmdbar.Controls("ControlName").Execute
End Sub

View | Toolbars will show you the names of your toolbars.

This could help you work out the right name for the individual controls:

Sub ShowTheControlNames()
    Dim oCmdbar As CommandBar
    Dim oCtl As CommandBarControl
    ' for example, let's look at the Standard toolbar:
    Set oCmdbar = Application.CommandBars("Standard")
    For Each oCtl In oCmdbar.Controls
        Debug.Print oCtl.Caption
    Next
End Sub

Note that your code won't work on non-English versions of PowerPoint ... the menu names are different.

Upvotes: 2

Related Questions