1 / 59

Word Project 8

Word Project 8. Working with Macros and Visual Basic for Applications (VBA). Objectives. Unprotect a document Set a security level in Word Crop a graphic Create a new style that is associated with a shortcut key Modify a style. Objectives. Modify a drawing object

otis
Download Presentation

Word Project 8

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. Word Project 8 Working with Macros and Visual Basic for Applications (VBA)

  2. Objectives • Unprotect a document • Set a security level in Word • Crop a graphic • Create a new style that is associated with a shortcut key • Modify a style

  3. Objectives • Modify a drawing object • Record and execute a macro • Customize toolbars and menus • View and edit a macro’s VBA code • Insert a VBA procedure

  4. Objectives • Run a macro when a user exits a form field • Insert an ActiveX control, set its properties, and write its VBA procedure • Work with the Protect Document task pane • Attach a digital signature to a document

  5. Unprotecting a Document • Follow the instructions on pages WD 557 – WD 558 to open Word and save the document with a new file name • Click Tools on the menu bar • Click Unprotect Document on the Tools menu • Click the Close button on the Protect Document task pane title bar

  6. Unprotecting a Document

  7. Setting a Security Level in Word • Click Tools on the menu bar and then point to Macro • Click Security on the Macro submenu • When Word displays the Security dialog box, if necessary, click the Security Level tab • Click Medium • Click the OK button

  8. Setting a Security Level in Word

  9. Cropping a Graphic • Click the Crop button on the Picture toolbar • Drag the right-middle cropping handle leftward to the location of the mouse pointer shown in figure 8-9 on page WD 565 • Release the mouse button • Click the Crop button on the Picture toolbar again

  10. Cropping a Graphic

  11. Creating a Style Associated with a Shortcut Key • Click the Styles and Formatting button on the Formatting toolbar • When Word displays the Styles and Formatting task pane, click the New Style button • When Word displays the New Style dialog box, type DataEntryArea in the Name text box • Click the Style type box arrow and then click Character • In the Formatting area, click the Font box arrow and then click Century Gothic, click the Font Size box arrow and then click 11, click the Bold button (if necessary), and click the Font Color button arrow and then click Dark Red on the color palette

  12. Creating a Style Associated with a Shortcut Key • Click the Format button • Click Shortcut key on the Format button menu • When Word displays the Customize Keyboard dialog box, press ALT+D • If necessary, click the Save changes in box arrow and then click A+ Dentist Locator Revised

  13. Creating a Style Associated with a Shortcut Key • Click the Assign button • Click the Close button to close the Customize Keyboard dialog box • Click the OK button in the New Style dialog box • Click the Close button on the Styles and Formatting task pane title bar

  14. Creating a Style Associated with a Shortcut Key

  15. Modifying a Style • Click the Styles and Formatting button on the Formatting toolbar • When Word displays the Styles and Formatting task pane, if necessary scroll through the list of styles until DataEntryArea appears in the list • Right-click DataEntryArea in the list • Click Modify in the list

  16. Modifying a Style • When Word displays the Modify Style dialog box, click the Font Color button arrow and then click Dark Blue on the color palette • Click the OK button • Click the Close button on the Styles and Formatting task pane title bar • If necessary, scroll to display the entire form in the document window

  17. Modifying a Style

  18. Filling a Drawing Object with a Preset Color Scheme Fill Effect • Select the rectangle by pointing to one of its edges and then clicking when the mouse pointer has a four-headed arrow attached to it • If the Drawing toolbar is not displayed on your screen, click the Drawing button on the Standard toolbar • Click the Fill Color button arrow on the Drawing toolbar and then click the Fill Effects button • When Word displays the Fill Effects dialog box, if necessary, click the Gradient tab

  19. Filling a Drawing Object with a Preset Color Scheme Fill Effect • In the Colors area, click Preset • Click the Preset colors box arrow, scroll to and then click Parchment • Click the OK button

  20. Filling a Drawing Object with a Preset Color Scheme Fill Effect

  21. Recording a Macro and Assigning It a Shortcut Key • Double-click the REC status indicator on the status bar • When Word displays the Record Macro dialog box, type PrintFormData in the Macro name text box • If necessary, click the Store macro in box arrow and then click Documents Based On A+ Dentist Locator Revised • Select the text in the Description text box and then type Prints only the data on a form • Click the Keyboard button

  22. Recording a Macro and Assigning It a Shortcut Key • When Word displays the Customize Keyboard dialog box, press ALT+P • Click the Assign button • Click the Close button in the Customize Keyboard dialog box • Click File on the menu bar • Click Print on the File menu

  23. Recording a Macro and Assigning It a Shortcut Key • When Word displays the Print dialog box, click the Options button • When Word displays the second Print dialog box, place a check mark in the Print data only for forms check box • Click the OK button in each dialog box • Click the Stop Recording button on the Stop Recording toolbar

  24. Recording a Macro and Assigning It a Shortcut Key

  25. Running a Macro • Press ALT+P

  26. Adding a Button to a Toolbar • Click Tools on the menu bar • Click Customize on the Tools menu • When Word displays the Customize dialog box, if necessary, click the Commands tab • Scroll to and then click Macros in the Categories list

  27. Adding a Button to a Toolbar • Click TemplateProject.NewMacros.PrintFormData in the Commands list • Drag the selected command in the Commands list to the Standard toolbar between the Print and Print Preview buttons • Right-click the button just added to the Standard toolbar and then point to Change Button Image on the shortcut menu

  28. Adding a Button to a Toolbar • In the palette of button images, click the button with the image of the text on pages • Right-click the button just added to the Standard toolbar • Click Text Only (in Menus) • Click the Close button in the Customize dialog box

  29. Adding a Button to a Toolbar

  30. Deleting a Button from a Toolbar • Click Tools on the menu bar and then click Customize • Right-click the button to be deleted, in this case, the Print Form Data button • Click Delete on the shortcut menu • Click the Close button in the Customize dialog box

  31. Deleting a Button from a Toolbar

  32. Viewing a Macro’s VBA Code • Click Tools on the menu bar and then point to Macro • Click Macros on the Macro submenu • When Word displays the Macros dialog box, if necessary, click the Macros in box arrow and then click A+ Dentist Locator Revised (template) • If necessary, click AutoNew in the Macro name list • Click the Edit button

  33. Viewing a Macro’s VBA Code • If the Code window is not displayed in the Visual Basic Editor, click View on the menu bar and then click Code • If the Project Explorer window is displayed, click its Close button • If the Properties window is displayed, click its Close button • If the Code window is not maximized, double-click its title bar

  34. Viewing a Macro’s VBA Code

  35. Modifying Existing Code • Double-click the 6 at the end of the executable code statement above the End Sub statement • Type 7 as the new number of lines to scroll

  36. Inserting a Visual Basic Procedure • Press ALT+F11 to open the Visual Basic Editor in a new window • If the Project Explorer is displayed, click its Close button • If the Properties window is displayed, click its Close button • If the Code window is not displayed, click View on the menu bar and then click Code

  37. Inserting a Visual Basic Procedure • If necessary, double-click the title bar of the Code window to maximize it • Click the Insert UserForm button arrow on the Standard toolbar • Click Procedure in the list • When Visual Basic displays the Add Procedure dialog box, type RatingScaleValidation in the Name text box • Click the OK button

  38. Inserting a Visual Basic Procedure

  39. Running a Macro when a User Exits a Form Field • Double-click the text form field for the rating scale • When Word displays the Text Form Field Options dialog box, click the Exit box arrow and then click RatingScaleValidation • Click the OK button

  40. Running a Macro when a User Exits a Form Field

  41. Inserting an ActiveX Control • If the Control Toolbox toolbar is not displayed on the screen already, click View on the menu bar, point to Toolbars, and then click Control Toolbox • If formatting marks are not displayed on the screen already, click the Show/Hide ¶ button on the Standard toolbar • Click the paragraph mark at the end of the form and then press the ENTER key • Click the Center button on the Formatting toolbar • Click the Command Button button on the Control Toolbox toolbar

  42. Inserting an ActiveX Control

  43. Setting Properties of an ActiveX Control • With the command button selected and Word in design mode, click the Properties button on the Control Toolbox toolbar • When the Properties window opens, if necessary, click the Properties box arrow and then click CommandButton1 in the list • If necessary, click the Alphabetic tab • If necessary, drag the right edge of the Properties window to make it wider

  44. Setting Properties of an ActiveX Control • In the list, click Caption in the left column and then drag through the value, CommandButton1, to its right • Type Click Here When Finished as the new caption • Click the AutoSize property • Click the AutoSize button arrow and then click True

  45. Setting Properties of an ActiveX Control • Click the BackColor property, click the BackColor button arrow, click the Palette tab, and then click Dark Red on the color palette • Click the ForeColor property, click the ForeColor button arrow, click the Palette tab, and then click Tan on the color palette • Click the Font property • Click the button at the right of the Font value box

  46. Setting Properties of an ActiveX Control • When Word displays the Font dialog box, scroll through the Font list and click Rockwell; if necessary, click Bold in the Font style list; and then click 12 in the Size list • Click the OK button • If necessary, click the A+ Dentist Locator Revised – Microsoft Word program button on the taskbar to redisplay the form on the screen • Click the Close button on the Properties window title bar

  47. Setting Properties of an ActiveX Control

  48. Entering the Click Here When Finished Button Procedure • With Word in design mode, click the Click Here When Finished button and then point to the View Code button on the Control Toolbox toolbar • Click the View Code button • If the Project Explorer window opens, click its Close button • If necessary, double-click the Code window title bar to maximize the window • With the insertion point on the blank line between the Sub and End Sub statements in the Code window, type the code statements shown in lines 2 through 15 in Table 8-8 on page WD 611. Make sure you type an apostrophe at the beginning of each comment line. For clarity, indent the code statements as shown in Table 8-8

  49. Entering the Click Here When Finished Button Procedure • Verify your code statements by comparing them to Figure 8-68 on page WD 613 • Click the Close button on the right edge of the Microsoft Visual Basic title bar to return to the online form • Click the Exit Design Mode button on the Control Toolbox toolbar • Click the Close button on the Control Toolbox toolbar title bar

  50. Entering the Click Here When Finished Button Procedure

More Related