Create Toolbar


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:

click to expand
Figure 17-5: Custom Toolbar with Macros

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.

start sidebar
Tip 52: Want more button faces?

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

end sidebar
 

If you want to change the rest of the buttons, feel free to do so. When I finished mine, the toolbar looked like this:


Figure 17-6: Custom Macro Toolbar with Icons

Close the customize window. You have created a macro toolbar!

start sidebar
Tip 53: Customize all of PowePoint

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.

end sidebar
 

Create A Combined Macro And Add To The Toolbar

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:

click to expand
Figure 17-7: Macro Toolbar with Combined Macro

What If Larry's Pages Weren't Next To Each Other?

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 



Kathy Jacobs On PowerPoint
Kathy Jacobs On PowerPoint
ISBN: 972425861
EAN: N/A
Year: 2003
Pages: 166

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net