1 / 48

PowerPoint Project 5

PowerPoint Project 5. Working with Macros and Visual Basic for Applications (VBA). Objectives. Create a toolbar Customize a toolbar by adding buttons Use the macro recorder to create a macro Customize a menu by adding a command Open a presentation and print it by executing a macro.

artie
Download Presentation

PowerPoint Project 5

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. PowerPoint Project 5 Working with Macros and Visual Basic for Applications (VBA)

  2. Objectives • Create a toolbar • Customize a toolbar by adding buttons • Use the macro recorder to create a macro • Customize a menu by adding a command • Open a presentation and print it by executing a macro

  3. Objectives • Create a form to customize a presentation • Create a user interface • Add controls, such as command buttons and combo boxes, to a form • Assign properties to controls • Write VBA code to create a unique presentation

  4. Creating a Custom Toolbar • Open the Travel presentation from your Data Disk in Microsoft Office PowerPoint 2003, according to the instructions on pages PPT 349 – PPT 350 • Click Tools on the menu bar and then point to Customize • Click Customize • If necessary, when the Customize dialog box appears, click the Toolbars tab • Click the New button

  5. Creating a Custom Toolbar • When the New Toolbar dialog box appears, type Vacation in the Toolbar name text box • Click the OK button • Click the Close button in the Customize dialog box • Click the Vacation toolbar and drag it to the bottom-right corner of the screen beside the Drawing toolbar

  6. Creating a Custom Toolbar

  7. Adding Two Buttons to the Vacation Toolbar • Click the Toolbar Options button on the new toolbar • Point to Add or Remove Buttons, and then point to Customize on the Add or Remove Buttons submenu • Click Customize • When the Customize dialog box is displayed, click the Commands tab • Scroll down in the Commands list and then click Save as Web Page

  8. Adding Two Buttons to the Vacation Toolbar • Drag the Save as Web Page command from the Commands list to the new Vacation toolbar • Scroll down in the Commands list and then click Package for CD • Drag the Package for CD command from the Commands list to the right of the Save as Web Page button on the Vacation toolbar • Click the Modify Selection button and then point to Change Button Image • When the Change Button Image palette is displayed, point to the button with three circles (row 6, column 4)

  9. Adding Two Buttons to the Vacation Toolbar • Click the button with the three circles image • Click the Modify Selection button and then point to Default Style • Click Default Style • Click the Close button in the Customize dialog box

  10. Adding Two Buttons to the Vacation Toolbar

  11. Recording a Macro • Click Tools on the menu bar, point to Macro, and then point to Record New Macro on the Macro submenu • Click Record New Macro • When the Record Macro dialog box is displayed, type PrintHandout in the Macro name text box • Type Macro prints Pure Black and White handouts in vertical slide order in the Description text box • Make sure the Store macro in box displays Vacation Central

  12. Recording a Macro • Click the OK button • Click File on the menu bar and then click Print • When the Print dialog box is displayed, click the Print what box arrow and then click Handouts • Click the Slides per page box arrow in the Handouts area and then click 4 • Click Vertical order in the Handouts area

  13. Recording a Macro • Click the Color/grayscale box arrow and then click Pure Black and White • Click the OK button • Click File on the menu bar and then click Print • When the Print dialog box is displayed, click the Color/grayscale box arrow and then click Grayscale (or your computer’s default print option) • Click the Slides per page box arrow in the Handouts area and then click 6

  14. Recording a Macro • Click Horizontal order in the Handouts area • Click the Print what box arrow and then click Slides • Click the OK button • Point to the Stop Recording button • Click the Stop Recording button

  15. Recording a Macro

  16. Adding a Command to a Menu, Assigning the Command to a Macro, and Invoking the Command • Click Tools on the menu bar and then click Customize • If necessary, when the Customize dialog box is displayed, click the Commands tab • Scroll down in the Categories list and then click Macros • Click File on the menu bar to display the File menu • Drag the PrintHandout entry from the Commands list in the Customize dialog box immediately below the Print command on the File menu

  17. Adding a Command to a Menu, Assigning the Command to a Macro, and Invoking the Command • Right-click PrintHandout on the File menu and then click the Name label on the shortcut menu • Type Print BW Handout as the new name of this command • Click the Close button at the bottom of the Customize dialog box • Click File on the menu bar and then point to Print BW Handout • Click Print BW Handout on the File menu

  18. Adding a Command to a Menu, Assigning the Command to a Macro, and Invoking the Command

  19. Opening a Presentation with a Macro and Executing the Macro • With PowerPoint active, click File on the menu bar and then click Open • If necessary, when the Open dialog box is displayed, click the Look in box arrow, and navigate to the folder where your files are stored • Double-click the file name, Vacation Central • If the Security Warning dialog box is displayed, click the Enable Macros button • When Slide 1 of the Vacation Central presentation is displayed, click File on the menu bar and then click Print BW Handout

  20. Opening a Presentation with a Macro and Executing the Macro

  21. Opening the Visual Basic IDE and a New Form • With the Vacation Central presentation still open, click Tools on the menu bar, point to Macro, and then point to Visual Basic Editor • Click Visual Basic Editor • If the VBA code displays, click the Close button in the upper-right corner of the Vacation Central - Module 1 (Code) window. You may need to drag the window to the left to view this Close button

  22. Opening the Visual Basic IDE and a New Form • Click Insert on the menu bar and then point to UserForm • Click UserForm • If the Toolbox does not display, click the Toolbox button on the Standard toolbar

  23. Opening the Visual Basic IDE and a New Form

  24. Changing the Form Size and the Toolbox Location • Without releasing the mouse button, drag the form window’s bottom border down • Release the mouse button • Without releasing the mouse button, drag the form’s bottom-center sizing handle down • Release the mouse button • Click the Toolbox title bar and drag it to the lower-right side of the form window

  25. Changing the Form Size and the Toolbox Location

  26. Adding Label and Combo Box Controls to a Form • Click the Label button in the Toolbox • Position the mouse pointer in the upper-left corner of the form • Click the mouse button • Click the ComboBox button in the Toolbox

  27. Adding Label and Combo Box Controls to a Form • Position the mouse pointer below the Label1 control • Click the mouse button • Repeat the previous steps to add the second and third Label controls and second and third ComboBox controls to the form as shown on the following slide

  28. Adding Label and Combo Box Controls to a Form

  29. Adding Command Button Controls to a Form • Click the CommandButton button in the Toolbox • Position the mouse pointer in the lower-left corner of the form • Click the mouse button • Repeat the previous steps to add a second CommandButton control, CommandButton2, as shown on the following slide

  30. Adding Command Button Controls to a Form

  31. Setting the Controls’ Caption Properties • Click the Label1 control • With the Label1 control selected, click Caption on the Alphabetic tab in the Properties window • Double-click the current caption, Label1, to select it, type Add a background as the caption, and then press the ENTER key • Change the captions for the remainder of the controls on the form using the information from Table 5-5 on page PPT 385

  32. Setting the Controls’ Caption Properties

  33. Resizing and Repositioning Controls on a Form • Click the Label1 control, Add a background • Change its Top, Left, Height, and Width properties in the Properties window to those listed in Table 5-6 on page PPT 386 • One at a time, select the controls and change their Top, Left, Height, and Width properties to those listed in Table 5-6

  34. Resizing and Repositioning Controls on a Form

  35. Entering the Create Presentation Procedure • Click the Insert UserForm button arrow on the Standard toolbar and then point to Module • Click Module in the Insert UserForm list • When the Visual Basic Editor opens, click the Maximize button in the Vacation Central - [Module2 (Code)] window • Type the seven comment statements (lines 1 through 7) shown in Table 5-7 on page PPT 388. Be certain to enter an apostrophe at the beginning of each comment line

  36. Entering the Create Presentation Procedure • Press the ENTER key to position the insertion point on the next line • Enter lines 8 through 10 shown in Table 5-7 on page PPT 388. Do not enter the End Sub statement (line 11). For clarity, indent all lines between the Sub statement and End Sub statement by three spaces • Click the Close Window button on the right side of the menu bar

  37. Entering the Create Presentation Procedure

  38. Entering the InitializeForm() Procedure • With UserForm1 selected in the Project window, point to the View Code button at the top of the Project Explorer window • If UserForm1 is not selected, click the form • Click the View Code button • Enter the VBA code shown in Table 5-10 on page PPT 392

  39. Entering the InitializeForm() Procedure

  40. Entering the CommandButton1 Procedure • Click the Object box arrow at the top of the Code window, and then point to CommandButton1 in the Object list • Click CommandButton1 • Make sure Click is in the Procedure box • Enter the VBA code shown in lines 1 through 12 in Table 5-12 on page PPT 394. Do not press the ENTER key after typing the End With statement in line 12

  41. Entering the CommandButton1 Procedure

  42. Entering the CommandButton2 Procedure • Click the Object box arrow in the Code window, and then click CommandButton2 in the Object box • Make sure Click is in the Procedure box • Enter the VBA code shown in Table 5-15 on page PPT 397

  43. Entering the CommandButton2 Procedure

  44. Initializing a Path Constant • Click the Object box arrow and then click (General) • Type Const Path = "c:\", replacing c with the actual location of the video and photo files on your system. Make sure a \ is at the end of your path • Press the ENTER key • Type Dim Templname As String and then press the ENTER key

  45. Initializing a Path Constant

  46. Summary • Create a toolbar • Customize a toolbar by adding buttons • Use the macro recorder to create a macro • Customize a menu by adding a command • Open a presentation and print it by executing a macro

  47. Summary • Create a form to customize a presentation • Create a user interface • Add controls, such as command buttons and combo boxes, to a form • Assign properties to controls • Write VBA code to create a unique presentation

  48. PowerPoint Project 5 Complete

More Related