Home

Wiley Word 2007 All-in-One Desk Reference For Dummies

image

Contents

1. Don t open documents from people you macro feature to infect your computer As a don t know or trust especially documents result you need to take some steps to protect that arrive as attachments in unsolicited yourself from the possibility of being hit by a e mail messages macro virus Here are some things you can do ee gs y I nstall an antivirus program These pro 1 Set your macro security to at least the grams sniff out and smash all known macro Medium setting to protect yourself from viruses aS well as other more common malicious macros To set the macro secu types of viruses and worms rity click the Macro Security button on the Developer tab on the Ribbon Then choose the security level you re most comfortable with
2. Using Auto Macros ar An auto macro is a macro that runs automatically whenever some key event happens such as when Word starts or when a document closes Word recog nizes auto macros by their names For example a macro named AutoNew automatically runs when you create a new document from a template and a macro named AutoClose automatically runs when you close a document To create an auto macro you simply create a macro by using one of the following special macro names AutoExec Runs when Word starts Store it in the Normal dotm template AutoExit Runs when Word exits Store it in the Normal dotm template AutoNew Runs whenever a new document is created by using the tem plate that contains the AutoNew macro AutoOpen Runs whenever an existing document opens You can create an AutoOpen macro in the Normal dotm template or in the template that s attached to the document Or both AutoClose Runs whenever an open document closes This macro can reside in Normal dotm or in the template attached to the document You can prevent any auto macro from executing by holding down the Shift key while performing the action that otherwise triggers the macro For exam ple holding down the Shift key while creating a new document prevents the AutoNew macro from running Book IX Chapter 1 soe usn pue Gulpios9y 5 68 Using Auto Macros ING s Macro security Computer viruses can exploit Word s auto
3. the macro was 10 point Times New Roman font every time you apply the macro the font is switched to 10 point Times New Roman You can avoid these side effects in two ways v Avoid recording dialog boxes in macros whenever a keyboard shortcut or a Ribbon button can do the trick Whenever you record a dialog box in a macro you record all the dialog box s settings v Fixthe macro later by editing it and remov ing the extraneous information See the section Editing a Macro can run it by following these steps 1 Select the Developer tab on the Ribbon and then click the Macros button in the Code group ar The Macros dialog box shown in Figure 1 3 appears As a shortcut you can press Alt F8 Macros wy Macro name BoldItalic BoldItalic strikethrough Macrosin All active templates and documents A Description Figure 1 3 The Macros dialog box Run step into Edt create ekte Organizer Book IX Chapter 1 soley usn pue Hulpios9y 5 64 Editing a Macro 2 If the macro you want to run isn t already selected select it now If the macro you want doesn t appear try changing the Macros In setting The macro might be in a different template 3 Click Run Editing a Macro If you make a mistake while recording a macro you can abandon the record ing and start over Or you can finish the recording and edit the macro to cor rect the mistake When you ed
4. ind Colt Project usema nag Normal E i ienest Wors coperts rund A Newton E BG Propert thorcho1 WWE Project TOC Weed 2007 fru meatreatascs Mwdwctica Pont Sald wdToay Selsctica Font Italic wdIcggle Fra mun Figure 1 4 Editing a macro Simple Macro Edits That Don t Require a Ph D in VBA Before you make massive changes to a macro you need a pretty good knowl edge of VBA However you can make certain types of changes without know ing much about VBA at all Here s a sampling Correct spelling errors If you inserted text into a document and mis spelled it don t hesitate to edit the macro to correct the misspellings Text you insert into a document while recording a macro is included in a Selection TypeText command like this Selection TypeText Text This is some simple text You can correct any spelling mistakes or change the inserted text alto gether provided you take care not to remove either of the quotation marks that appear before and after the text For example you can cor rect the preceding line to Selection TypeText Text This is some sample text Book IX Chapter 1 sode Huisp pue uip1o3 y 566 Simple Macro Edits That Don t Require a Ph D in VBA Remove extraneous commands If you inadvertently used a command while recording a macro you can clean up your macro by removing the unnecessary command Remove unwanted dialog box s
5. 2 Think about what you re going to do Think through all the steps you have to follow to accomplish whatever task you want to automate with a macro To create a macro that makes text bold and italic for example all you have to do is press Ctrl B and then press Ctrl I That s a pretty simple macro but other macros can be much more complex involving dozens of steps If necessary rehearse the steps before you record them as a macro 3 Click the Developer tab on the Ribbon and then click the Record Macro button in the Code group The Record Macro dialog box appears as shown in Figure 1 1 wt Record Macro Macro name Macrol Assign macro to 2 Button pee Store macro in A Keyboard All Documents Normal dotm v Description poran Cancel Book IX Chapter 1 soe Huis pue uip1o3 y 560 lt r Figure 1 2 Assigning a macro toa keyboard shortcut Doing the Macro Recorder Dance If the Developer tab isn t visible choose OfficeWord Options to summon the Word Options dialog box Then click the Personalize tab and select the Show Developer Tab in the Ribbon check box Type the name of the macro you want to create in the Macro Name text box The name can be anything you want but it cannot include spaces commas or periods When the Record Macro dialog box first appears the macro name is set to something like Macrol or Macro2 or Macro783 if you ve been busy
6. Chapter 1 Recording and Using Macros In This Chapter Recording a macro 1 Running a macro Editing a macro Using auto macros A macro is a sequence of commands or keystrokes that Word records and lets you play back at any time Macros allow you to create your own customized shortcuts for tasks you do over and over again For exam ple Word comes with built in keyboard shortcuts to make text bold Ctrl B and to make text italic Ctrl D but no built in shortcut exists to make text bold and italic all at the same time To perform that formatting task you have to press Ctrl B and then press Ctrl I If you do that a million times a day pretty soon that extra keystroke becomes bothersome Wouldn t having a shortcut for bold italic be nice With Word s macro recorder you can create one This chapter shows you how to record and play back simple macros It doesn t show you how to create complex macros by using Word s macro programming language Visual Basic for Applications That s the topic of the remaining chapters in this minibook 55 8 Where Do all the Macros Go Where Do All the Macros Go You can store macros in documents or in templates When you create a macro you have three choices for where to store the macro The current document This is the best place to create macros that you will use only in a single document The template that s attached to the current document if it is macro enabled This is the be
7. Surely you can come up with a better name than that I know Yes I can and stop calling me Shirley To make your macro accessible from a toolbar or the keyboard click the Button or Keyboard button This step calls up the Customize dialog box which is ready to add your macro to a toolbar the Ribbon or a keyboard shortcut Figure 1 2 shows the Customize Keyboard dialog box that Word displays if you click the Keyboard button Type the shortcut key combination you want to assign to the macro in this case I pressed Alt Ctrl B click the Assign button and then click Close Customize Keyboard wt Speafy a command Save changesin Normal dotm v Current keys Press new shortcut key Currently assigned to unassigned scription Commands Normal NewMacros Macro2 Alt Ctrl 8 If you click the Button button instead the Word Options dialog box appears with the Customize tab selected Then you can create a button on the Quick Access toolbar to run the macro For more information refer to Book VIII Chapter 1 IIO Pause Recording T Stop Recording ar 6 9 10 11 12 Doing the Macro Recorder Dance 561 Set the Store Macro In drop down list to the location where you want to store the macro The default setting stores the recorded macro in the Normal dotm tem plate so that it s always available The other choices available in this drop down list are storing the mac
8. ated Page Up or Page Down keys for this purpose Pressing Page Up three times might get you to the top of your document when you record the macro but when you run the macro it might not Similarly use Home and End to move to the start or end of a line rather than the left or right arrow keys If you use the Find or Replace commands be sure to move to the begin ning of the document first Avoid any commands that depend on the contents of a document that s active when you record the macro If your macro is based on informa tion that will never be replicated it s a pretty useless macro Running a Macro If you assigned a macro to the Quick Access toolbar the Ribbon or a key board shortcut you can run the macro by clicking the QAT button choosing Sometimes a macro has unexpected side effects Suppose that rather than record the keystrokes Ctrl B and Ctrl I for the Bolditalic macro you decide to record these steps instead 1 Call up Format gt Font 2 Choose Bold Italic as the font style 3 Click OK The macro seems to work but sooner or later you discover that in addition to recording the Bold Italic font style the macro recorded other character attributes such as font size and effects If the text to which you applied the the Ribbon command or pressing the keyboard shortcut If you didn t you Running a Macro 5 63 Avoiding unexpected side effects Format gt Font command when you recorded
9. ettings If you record a dialog box ina macro Word includes every setting in the dialog box You can remove the settings that you do NOT WANT the macro to change For example if you use Font dialog box to format text with small caps Word inserts the following commands into the macro With Selection Font Name Times New Roman Size 9 5 Bold False Italic False Underline wdUnderlineNone UnderlineColor wdColorAutomatic Sstrikethrough False DoubleStrikeThrough False Outline False Emboss False Shadow False Hidden False SmallCaps True AllCaps False Color wdColorAutomatic Engrave False Superscript False Subscript False Spacing 0 3 Scaling 100 Position 0 Kerning 0 Animation wdAnimationNone End With This command looks complicated at first but if you study it you see that it is little more than a list of all the dialog box controls that appear in the Font dialog box The periods look strange appearing in front of each command argument as they do but they re required You can safely delete the lines that specify those dialog box controls you don t want to use so that the resulting command looks like this With Selection Font SmallCaps True End With e Using Auto Macros 5 67 Actually with a little more VBA knowledge you can also remove the With and End With commands and substitute just the following Selection Font SmallCaps True
10. in mind as you record macros You can call up the Record Macro dialog box directly by clicking the Record Macro button on the status bar It appears as a little red dot Ifthe macro doesn t work you might have made a mistake while record ing it If the macro is short enough the best thing to do is to record the macro again If the macro is long and you don t have anything important to do try editing the macro to expunge the problem See the section Editing a Macro later in this chapter Macros are normally stored in the global Normal dotm template To store a macro in the template attached to the current document change the set ting of the Record Macro dialog box s Store Macro In drop down list ay Don t make any assumptions about where the insertion point will be when you run the macro If necessary begin the macro with a position ing command by moving the insertion point to the beginning of the doc ument the beginning of the line or the beginning of a word Not all macros require a positioning command But if your macro depends in any way on the position of the insertion point this step is a must MBER y Re Don t use the mouse to select text or navigate through the document Word doesn t record these mouse actions You can use the mouse to select Ribbon commands but not to move the insertion point Use Ctrl Home or Ctrl End to move to the beginning or end of a docu ment Don t use repe
11. it the macro the macro s commands appear in a separate window You can delete or modify erroneous commands you can insert new commands if you know how or you can merely study the macro to try to figure out how it works When you edit a macro you re exposed to Visual Basic for Applications VBA VBA is not as deadly as the Ebola virus but it can cause severe headaches and nausea if you re not inoculated with the Programmer Vaccine For more information about VBA and its editor turn to Chapter 2 of this minibook Here are the steps for editing a macro 1 Click the Macros button on the Developer tab on the Ribbon or on the status bar The Macros dialog box appears Refer to Figure 1 3 2 Select the macro you want to edit and click the Edit button Word launches the Visual Basic editor with the macro you selected visi ble in its own window See Figure 1 4 Notice that the Visual Basic editor uses good old fashioned menus instead of the new fangled Ribbon 3 Make whatever changes are necessary to the macro Correct misspelled words delete extraneous commands and if you re brave add more commands 4 Choose FileSave Template to save your changes 5 Choose File gt Close to close the macro window Simple Macro Edits That Don t Require a Ph D in VBA 565 MictveoN Viewal Basic Normal zag File Edit View Insert Format Debug Run Taels Add Ins Window Help pte queston for hes Ei C FEET 9m gt wae BSS
12. ro in the document that you were working on when you called up the macro recorder or storing the macro to the template that document is based on Click OK to begin recording the macro Type the keystrokes and Ribbon commands you want to record in the macro To record the BoldItalic macro for example press Ctrl B and then press Ctrl I If you have to stop recording temporarily click the Pause button Click it again to resume recording You might forget how to do something for example especially if you skipped Step 2 If you click the Pause button you can call up Word s Help command look up the procedure for whatever it is you forgot dismiss Help and click the Pause button again to resume recording After you finish recording the macro click the Stop button Word adds the macro to the template or document You re almost done Test the macro If you assigned the macro to a keyboard shortcut use the shortcut now to see whether the macro works Otherwise follow the steps in the later section Running a Macro You re finished Congratulate yourself If the function of the macro isn t obvious from the macro name type a more elaborate description of the macro in the Record Macro dialog box s Description field You ll thank yourself later when you forget what the macro does Book IX Chapter 1 soe usn pue uip1o3 y 562 Macro Recording Tips Macro Recording Tips Here are some tips to keep
13. st place to create macros that you want to use in a large number of similar documents Then the macros will be available to any document you create from the template The Normal dotm template This is the place to create macros that you want to be available all the time no matter what document you are working on Note If the current document is based on Normal dotm you really have only two choices the current document or the Normal dotm template When you create a macro you need to think about when you re going to want to run the macro If you need to run the macro only from within a spe cific document create the macro in that document If you want the macro to be available only to documents based on a particular template create the macro in that template But if you want the macro to always be available no matter what document you re working on store the macro in Normal dotm Actually you can store macros in a fourth place in a global template A global template is a great place to create a library of macros that are avail able to all of your documents For more information about using global tem plates turn to Book I Chapter 3 Note To create or edit macros in a global template you must open the template After you create macros in a tem plate you can close the template attach it as a global template and then run any macros it contains Doing the Macro Recorder Dance The easiest way to create a macro is
14. to use the macro recorder which is kind of like a videocassette recorder After you turn on the macro recorder it fol lows you around and makes a precise record of everything you do until you turn off the recorder Well not really everything The Word macro recorder records only the stuff you do in Word It doesn t notice when you dribble coffee down your chin or sneeze on the monitor But when you turn on the avr Figure 1 1 The Record Macro dialog box 559 Doing the Macro Recorder Dance recorder anything you do in Word whether you re typing text applying formatting calling up a command or filling out a dialog box is carefully recorded Then when you turn off the recorder you can replay the recorded macro to repeat the exact sequence of steps that Word recorded in the macro About the only things that are not recorded by the macro recorder are mouse movements within the document The macro recorder records but tons or Ribbon choices you click but Word won t let you navigate about your document or select text with the mouse while the macro is recording As a result use the keyboard for navigating or selecting text while recording a macro To record a macro follow these steps 1 Try to talk yourself out of it Fiddling around with macros can be a bit of a time waster Ask yourself whether you really will use the macro after you go to the trouble of recording it If not go directly to Step 12

Download Pdf Manuals

image

Related Search

Related Contents

Extech 461825 Photo Tachometer / Stroboscope Manual  Interactive Trademark Search  A... PC COM 4 PORT R5232 CARD USER MANUAL  Manual del Propietario de las Series Viper  GA_TDC_1.SK_030 089/0_S.1-29.FR  American Dish Service Vision C3 User's Manual  ORiNOCO AP- 4000 - ソルテック・ソリューションデザイン株式会社  M2M 3350 GSM/GPRS Modem User`s Manual & Reference Guide  仕様書  卒業論文 題目:ガラス線量計のプレヒート処理の時期によるビルドアップ  

Copyright © All rights reserved.
Failed to retrieve file