Now that Larry has all of his macros defined, he would like to be able to run them without going through the macro interface every time. To do this, he needs to connect his macros to a toolbar.
To connect macros to a toolbar, first have a toolbar defined. Go to Tools ’ Customize and click on the Toolbars tab. Click the New button, give the toolbar a name and a new toolbar will appear on the PowerPoint desktop.
Next , click the Commands tab. Scroll down the list in the left hand box until you find Macros. Select it and a list of the macros should appear in the right hand box. Click and drag each of the macros to the toolbar. My toolbar looked like this:
Once the macro names are on the toolbar as buttons , change them to other text or icons. We are going to change the face of the ChangePage button to a graphic instead of text.
If you closed the Customize window, bring it back. Right-click on the ChangePage button, select Change Button Image, slide over and select an image for the button. Next, right-click the button again and click Default Style. This will change the button from text plus an image to just the image.
PowerPoint MVP Shyam Pillai has created an add-in that gives you all the possible button faces provided by Microsoft. Since most of these are hidden from you as a general user , this is one of the most useful add-ins available for macro developers. Find the add-in at http://www.mvps.org/skp/faceid.htm
If you want to change the rest of the buttons, feel free to do so. When I finished mine, the toolbar looked like this:
Close the customize window. You have created a macro toolbar!
Use the Customize window to change what shows on what menu and in what order, as well Customize as changing all of the toolbars and creating new ones.
Play around with creating your own toolbars. You will find it is a great way to make PowerPoint even more usable.
Being able to create a toolbar for the macros gave Larry an idea. He decided the next logical step in his project was to make one macro that would call each of the others in turn . Since it was going to use existing code, he knew it would prompt him for most of the inputs he needed.
To call one macro from inside another, you place the called macro name in the code area of the calling macro. Larry figured out the order in which he needed to call the macros and created a macro called UpdateToNewClient with this code:
Sub UpdateToNewClient() ' This macro calls the other macros to update the presentation to the new client information ' Macro created 1/20/2004 by Kathryn Jacobs ' CreateClientName CreateClientContact ChangePage CreateGoals End Sub
Once Larry had his new macro tested and ready to go, he added it to the existing toolbar and gave it an icon. When done, his new toolbar looked like this:
If Larry's presentation had slides between the contact information slide and the goals slide, he could make one of two changes to his macros. The first way would be to change the ChangePage macro so instead of adding one to the page location, he used a variable which asked for input using an InputBox. The other way to make the change is to change UpdateToNewClient so it called ChangePage the correct number of times.
To use a variable and an InputBox to make changes, create a new variable in ChangePage filled by an InputBox asking how many pages to skip. Then, instead of adding the number 1 to the current slide index, add the new variable to the current slide index. When complete, the code for ChangePage would look like this
PagesToSkip = InputBox("How many more slides until the goals slide?") ActiveWindow.View.GotoSlide Index:=ActiveWindow.Selection.SlideRange.Sli deIndex + PagesToSkip
To do it the other way, Larry needs to add a loop to his macro that will repeatedly call ChangePage until the right number of pages gets skipped .
First, he needs ask how many pages to skip. To do this, he creates the new variable in UpdateToNewClient and fills that variable using InputBox. He then uses a For loop to call the macro that number of times. A For loop says do this for every number between my start point and my end point.
After making the code adjustments, the UpdateToNewClient code looks like this:
Sub UpdateToNewClient() ' This macro calls the other macros to update the pitch presentation to the new client information ' Macro created 1/20/2004 by Kathryn Jacobs ' CreateClientName CreateClientContact PagesToSkip = InputBox("How many more slides until the goals slide?") For I = 1 To PagesToSkip ChangePage Next I CreateGoals End Sub