Introduction:
I wanted to convert a PowerPoint Macro to a PowerPoint Add-in so I could use the same macro code against multiple PowerPoint presentations, regardless of them being macro-enabled or not. For my purposes I needed this done in PowerPoint however I would imagine that the steps would some what similar for Excel and Word. Outlined are the steps I followed after visits to forums and Microsoft documentation.
Step 1: Create your macro.
For purposes of this discussion I assume you already know how to create a macro. If not please refer to the further reading links below.
Step 2: Paste the code from PPTFAQ.com in your Powerpoint: to create the tool bars. They have provided a piece of code which creates the tool bar and calls a function called Button1() to allow for testing. [please find the code at PPTFAQ.com]. All you need to do is edit the Button1() and replace with the function you would like called when the button is clicked on the toolbar.
Step 3: Create a Self-Signed Digital Certificate with the SelfCert.exe in the office folder under program files. This allows your macro to run as a trusted source, by letting the computer know that the code was written by you. Should you require your eventual add-in to be run on multiple PC’s you can either generate a self-cert for every PC (lots of effort), decrease the security setting (not recommended) to run untrusted macro’s or purchase a digital certificate to allow for your add-in to be distributed.
Step 4: Go to tools in your PowerPoint document, under Visual Basic code and select from the Tools menu, digital certificate.
Step 5: Assign your newly created Self-Signed Digital Certificate to your code. This allows you to execute your code after you converted it to an add-in.
Step 6: Save your file as a Macro enabled Office file , for PowerPoint this is a “.pptm” file extension.
Note: You have to save your file because once you save it as an add-in you cannot edit the code anymore.
Step 5: Now save your file as an Office add-in , example PowerPoint gives you the option to SaveAs a “.ppam” file extension.
Notice: add-ins do not get saved to your folders , they get saved in a trusted folder, in your documents/appdata (this folder is normally has the hidden attribute applied)
Step 6: Go to File, Options, Add-ins in your office application, click the drop down and select the Office application specific add-in, for example:
In PowerPoint you have “Com-in” as the default and under that is “PowerPoint add-in” this is the one you want.
Step 7: Select the “add-in” you have just saved
Step 8: Test, restart with another non-macro enabled file and see if your ribbon loads properly.
Further reading:
- Youtube videos on creating macros
- Powerpoint Macro intro
- Excel Macro intro
- Word Macro intro
- *There are a lot of video tutorials at different levels of granularity, you may want to search YouTube to find the level the best addresses your needs.
- PPTFAQ.com – Nice resource for Powerpoint, also sell add-ins
- Microsoft Self-Signed Digital Certifcate