Presentation on theme: "Macros/VBA Project Modules and Creating Add-Ins on the Toolbar"— Presentation transcript:
1Macros/VBA Project Modules and Creating Add-Ins on the Toolbar Using PowerPoint 2010By Linda Carrillo, SPSSOD Technical Liaison09/26/12Begin Trans –This presentation will go through the steps to create a VBA project module using Macro in Powerpoint It will also create an Add-In to execute that function with ease.
2Changing Macro Security First open a new PPT(X) and change the Macro security: File>Options>Trust Center>Trust Center Settings>Check Trust Access>OK>OKI have selected the Trust access to the VBA project object model, however I’m not sure if that generates an Enable window to appear later or not. Originally I did not have this selected and it worked just fine.
3Save the VBA codePut the VBA code (with auto open) in a text file and save it. This will take out any spaces and you can copy and paste with ease.The VBA code must have an auto open code so that each time you opened Powerpoint the Add-in will be an option.
4Getting to Macros VBA Project Modules Select Alt+F11>Insert Tab>ModuleThere is no need to bring in the Developer Tab Alt-F11 takes you right to the window you need.
5Insert the VBA Code and Debug it. Paste VBA Code> Debug> Compile VBA Project>Your code might need some debugging. For some reason mine added an enter in the middle of a line code causing it to fail. Debug> Compile VBA highlights the error and turns it red so you can easily correct it.
6Yes – to Macro Free Presentation File>Save PPT(X)You might get a Save File as a Macro-free presentation window. Just answer Yes.This might happen when saving your PPT.File>Save PPAM
7Show Hidden FilesIf you don’t already have hidden files turned off do so: My Computer> Tools> Folder Options> View> check show hidden files, folders, and drives> OKRemember to switch it back when you are done.Most UST computers have some systems files, folders, and drives hidden so the user won’t inadvertently delete them. You will need to show them to move your PPAM to a trusted location.
8Move the PPAMMove PPAM to trusted location: C drive> users> username> AppData> Roaming> Microsoft> AddIns
9File> Options> AddIns> under Manage select PowerPoint Add-in> GO This step will make the Add-Ins tab appear as an option.
10Select Add New and see that the PPAM is checked> Close. This step will make the button you want to execute appear as an option.
11New Add-In TabSelect the new Add-Ins Tab in PPT(X) and select the new button you just created.Here you can see the Add-In Tab and the button which executes the VBA project. This one was copied from the internet and the originator selected a little pig #52 as the icon. He also chose to say his name when you hoover over the icon. When I changed the name the code stopped working, so we’ll have to live with it for now.
12Output File Name Give the Output file a name>OK (Example: ElijaNotes092612)It’s good to add the date so when you make changes to the presentation you know which Notes you have.
13If you get a message that says your Macro Security needs to change, most likely your code has an error and you’ll need to start over.This is a very unfortunate message to get. The debugging didn’t catch whatever made it fail and unfortunately you will have to delete all PPT(X)’s and PPAM files and start over looking carefully at the VBA code.
14If you get a message that says it Couldn’t create the file, most likely you needed to save the ppt(x) and try again.Just forgot to save the presentation.
15Save the TXT It generates a txt file, save it, and print it. Or you can copy and paste the content to a word document to format differently.Success! It worked! Don’t forget to save it.
16Enable Macros WindowsYou might get a enable window when trying to work with old PPT(X)’s. Answer Yes. You will only have to do it once with each old PPT(X).Unfortunately, we get this message and I’m not sure if selecting the Trust the VBA in the Macro Security settings in the reason. Since it works, I didn’t want to risk changing it and having to start all over. You only have to do it once for each old presentation.
17DO NOT DELETE the PPT(X) What ever you do, do NOT delete the PPT(X) with the VBA project module attached. Put it someplace in a folder titled DO NOT DELETE. If you delete this PPT(X) the Add-in will not work for future presentations.The only time you should delete the PPT(X) that has the code is if you got that message that said you need to change your Macro Security, most likely there was something wrong with the VBA code the debugging didn’t catch. Only then will you delete the PPT(X) with the code and all PPAM’s and start over.– End Trans