Adding a macro from PowerPoint add-in to ribbon

我怕爱的太早我们不能终老 提交于 2020-01-24 09:23:13

问题


It's possible to add macros from a macro-enabled PowerPoint (pptm) presentation from the ribbon by right clicking in the ribbon and selecting Choose commands from: Macros.

I want this to be available at any time, so I've saved the pptm file as an add-in (ppam) and loaded the add-in.

However, I find that it is not possible to add the macro from the add-in in the ribbon. How can this be done? Do I somehow need to register all available Subs from Auto_Open or similar with something like:

Sub MyCommand()
MsgBox "This worked"
End Sub

Sub Auto_Open()
' Magic code allowing me to add the above to the ribbon
End Sub

Thanks! Troels


回答1:


You need to add special XML code to the PPTM file to make the ribbon mods you want and hook the button clicks to the VBA routines in the file. Google "Ribbon XML" (without quotes) for starters. There are a couple of decent free apps that help create/edit Ribbon XML.

The free Office RibbonX Editor by Fernando Andreu, available on GitHub is a good place to start: https://github.com/fernandreu/office-ribbonx-editor/ (or for the latest release: https://github.com/fernandreu/office-ribbonx-editor/releases/latest )

Ron DeBruin has a wealth of information about using RibbonX here: https://www.rondebruin.nl/win/s2/win001.htm

My bible on the subject has been RibbonX by Robert Martin, Ken Puls and Teresa Hennig (Wiley is the publisher). Available on Amazon.



来源:https://stackoverflow.com/questions/13842285/adding-a-macro-from-powerpoint-add-in-to-ribbon

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!