Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Creating and playing a macro

From: Word 2010 Essential Training

Video: Creating and playing a macro

If you have a series of steps that you complete in a number of different documents, or that you complete a number of times within a document or document set, that group of steps is a great candidate for a Macro. Macros are bundles of Visual Basic code that tell Word how to complete a particular task. While you can create Macros manually using the Visual Basic Editor, it's much easier to use Microsoft Word's built-in Macro Recorder to create and save your Macros.

Creating and playing a macro

If you have a series of steps that you complete in a number of different documents, or that you complete a number of times within a document or document set, that group of steps is a great candidate for a Macro. Macros are bundles of Visual Basic code that tell Word how to complete a particular task. While you can create Macros manually using the Visual Basic Editor, it's much easier to use Microsoft Word's built-in Macro Recorder to create and save your Macros.

Macros are created to solve a problem. The problem that I have here is that I have a lot of documents that were created a few years ago. At that time, when people typed in text and got to the end of a line, they would press the Enter key twice. When they got to the end of a sentence, they would press the Spacebar twice. They did those things because the software wasn't smart enough to automatically increase the space at the end of a paragraph, or to replace an end space with an em space at the end of a sentence.

Now, I have too much space in my document so that if I change to one of the newer styles, for example, something like modern, look at all of the space in this document, because we have not just the space that the original typist entered, but the space that Microsoft Word automatically puts into this document. So, rather than tell Word to quit doing what it does to style this document, I need to just get rid of all of the extra spaces and all of the extra carriage returns at the ends of paragraphs.

Rather than use this document, I have created a test document to allow us to create and test our Macro. So I am going to switch to that document now, because there is no reason to turn my mission-critical documents into guinea pigs. So here's my Test Document. It has the same kind of attributes as the document that I want to be able to reformat. So the first thing we are going to do is make sure that the conditions when our Macro runs are actually reflected in this document and in the current state of the document. Like my other document that I want to use this Macro on, I have two spaces at the end of sentences, two Carriage Returns at the end of paragraphs.

I don't have anything selected here, which is fine because selecting the entire document is going to be the first thing I do in my Macro. Two ways that I can find the command to record a Macro, if I have the Developer tab available. It's in the Code group, under Record Macro. If you don't have the Developer tab displayed, under View > Macros > Record Macro, you can click and either of those will open this same Record Macro dialog box. The first thing I need to do is give the Macro a decently descriptive name.

I'm going to call this SingleSpaceSingleCRReformat. Next, I want to provide a Description that says "This Macro converts double spaces and double carriage returns found in legacy documents to single spaces and CRs." I'm also going to make a note about who I am.

I am actually going to sign to this Macro in a way to say Created by me and how to find me. When I open a document that has Macros that aren't signed, that I can't necessarily tell what they do without going and opening the Visual Basic Editor, I get nervous, and I don't want to necessarily use that document or those Macros. So this is a way that at least people in the organizations that I work with who'll open this Macro would go yeah! We know who this person is.

Finally, two different locations to store my recorded Macro in, and I set those upfront. First, if this is a Macro that I want a used with one document only and I want the Macro to travel with the document, I'll save it in the document itself. For example, I could create a Macro that would sort a table in a document. Well, it's specific to that table. So I'll store in that document. But I want to create a Macro that I can use for a wide range of documents. So, I'm going to store it globally in Normal.dotm, which loads every time Microsoft Word is launched.

When I click OK, the Macro recorder begins running. You'll notice that my pointer changes so it has a small icon. I believe that's a cassette tape. I have to use some of my keyboard skills now because while we are just recording, and the pointer is that recorder icon, the Context menu is not enabled. So, when I right-click, nothing happens. I'll need to find another way to select all my text, like Ctrl+A. So, I've just recorded selecting all the text.

Now I'm going to choose the Home tab and click Replace to open the Find and Replace dialog box. There are two things I want to find. First, I want to find places where a space was typed twice. 1, 2 and replace everyone of those with one space I will replace them all at one time in my document. It says Word has done this 9 times. Do you want to search the remainder? This is sort of boilerplate text. We selected the whole document. So, there really is no remainder, and we'll simply say No.

Thank you for the replacements. So, now we don't have the extra space here. But we still have the two carriage returns. We want to search again, and I can't simply press the Enter key here. I actually need to include the character that's the Paragraph Mark. So, I'm going to click More. So I'll find the Paragraph Mark here where it says Special. Now I already have two spaces that I typed in this field. So I want to select those first and then say look for a Paragraph Mark followed by another Paragraph Mark.

So, that's all that's here. When I click in the Replace With Field, it still has the space from last time too. This is tricky stuff. So we want to make sure that we don't have that space here anymore, and that we replace two Paragraph Marks with one Paragraph Mark. I am going to click Replace All. It says 9 replacements were made. That makes sense. There's nine paragraphs. I don't need it to search anything else. Now, what I have is my document with only one carriage return at the end of each line, only one space between sentences.

I'm happy with this. I could end of my Macro now, but I'd like to end my Macro with this dialog box closed. So we are going to click Close to close the dialog, and then I'm going to stop the Macro Recorder. Three ways to do it. First, there is a button that I can click in the status bar while a Macro is recording. I can also go to the Developer tab > Stop Recording or to the View tab > Macros > Stop Recording. We are all done recording our Macro.

Now, I want to test it. I'm going to go back up to the two replacements that were made and undo them. Now my document is back the way it was before. I'm going to test my Macro. Either on the Developer tab, I can go to Macros, or on the View tab, I can go to Macros > View Macros. Here is my Macro and I want to Run it. It says Word has reached the end of the document. 9 replacements were made. So, this is my first dialog. Do I want to continue searching? No.

Here is my second one. No. There is my document. So, I can play this Macro back any time I want to, in any document I like. Are you tired of following the same steps and doing the same old grind with a series of documents? Just record a Macro, and let Microsoft Word do the necessary, but often mindless tasks in your document workday.

Show transcript

This video is part of

Image for Word 2010 Essential Training
Word 2010 Essential Training

89 video lessons · 56073 viewers

Gini Courter
Author

 
Expand all | Collapse all
  1. 5m 39s
    1. Welcome
      1m 8s
    2. Using the exercise files
      1m 34s
    3. Creating placeholder text
      2m 57s
  2. 33m 47s
    1. Using the Word interface
      8m 56s
    2. Understanding the Ribbon
      8m 10s
    3. Customizing the Quick Access toolbar
      3m 10s
    4. Using Word's document tools
      8m 5s
    5. Using the Navigation pane to find words or phrases in a document
      5m 26s
  3. 30m 53s
    1. Managing documents with Backstage view
      4m 42s
    2. Creating a new document from a template
      5m 11s
    3. Making it easy to find and open documents
      3m 59s
    4. Saving a Word document for yourself or others
      7m 1s
    5. Printing a document and choosing a printer
      3m 33s
    6. Setting print options
      6m 27s
  4. 24m 24s
    1. Selecting text using the mouse and keyboard shortcuts
      4m 57s
    2. Rearranging text using Cut, Copy, and Paste
      7m 38s
    3. Undoing and redoing actions
      4m 8s
    4. Finding and replacing text
      7m 41s
  5. 27m 40s
    1. Understanding fonts
      6m 32s
    2. Working with fonts
      5m 29s
    3. Applying basic formatting
      6m 25s
    4. Changing the case of text
      4m 22s
    5. Using text effects and adding impact to a document
      4m 52s
  6. 29m 44s
    1. Aligning and justifying paragraphs
      2m 55s
    2. Changing line spacing
      5m 2s
    3. Using indents and setting tabs
      7m 20s
    4. Creating a bulleted or numbered list
      6m 11s
    5. Keeping text together through page breaks
      4m 2s
    6. Applying shading and borders to paragraphs
      4m 14s
  7. 50m 10s
    1. Power formatting with styles
      7m 34s
    2. Changing a document's theme
      6m 59s
    3. Changing style sets, color sets, fonts, and paragraph spacing
      3m 31s
    4. Applying Quick Styles and clearing formatting
      5m 18s
    5. Creating a Quick Style set
      6m 24s
    6. Using the Navigation pane with styles
      3m 1s
    7. Easily creating a table of contents
      5m 32s
    8. Restricting formatting to a selection of styles
      4m 58s
    9. Creating a multilevel list using styles
      6m 53s
  8. 48m 1s
    1. Creating a table to organize text
      6m 11s
    2. Converting text to tables
      3m 36s
    3. Formatting tables for readability
      4m 8s
    4. Adding and removing columns
      5m 36s
    5. Sorting table data
      5m 19s
    6. Merging, splitting, and formatting cells to create a form
      8m 53s
    7. Converting a table to text
      2m 41s
    8. Inserting an Excel table for calculations and charts
      7m 18s
    9. Using Quick Tables
      4m 19s
  9. 1h 7m
    1. Illustrating documents with pictures, shapes, and clip art
      8m 43s
    2. Positioning, sizing, and cropping graphics
      6m 11s
    3. Wrapping text around graphics
      4m 54s
    4. Laying out text and graphics with a table
      6m 50s
    5. Adjusting brightness, contrast, and sharpness of photos
      4m 30s
    6. Applying special effects to graphics
      5m 4s
    7. Applying styles to graphics
      5m 40s
    8. Illustrating with charts: Inserting a chart from Excel
      8m 26s
    9. Illustrating with diagrams: Using SmartArt
      10m 22s
    10. Illustrating with screenshots: Capturing screenshots from your computer
      3m 17s
    11. Illustrating with WordArt
      3m 35s
  10. 34m 10s
    1. Understanding building blocks
      3m 41s
    2. Numbering pages and applying headers and footers
      6m 56s
    3. Adding cover pages and blank pages
      3m 50s
    4. Using text boxes for document design
      8m 16s
    5. Creating and saving custom headers and footers
      6m 21s
    6. Creating and saving Quick Parts
      5m 6s
  11. 23m 40s
    1. Setting page margins, page orientation, and paper size
      6m 30s
    2. Inserting sections to organize a document
      5m 17s
    3. Using columns
      5m 23s
    4. Using watermarks, page borders, and colors
      6m 30s
  12. 20m 15s
    1. Checking spelling and grammar
      5m 6s
    2. Setting proofing and AutoCorrect options
      7m 21s
    3. Using the Thesaurus and Research and Translation tools
      7m 48s
  13. 21m 3s
    1. Tracking changes and showing markup
      5m 29s
    2. Accepting and rejecting changes
      4m 35s
    3. Comparing and combining documents
      6m 42s
    4. Coauthoring documents with SharePoint
      4m 17s
  14. 40m 56s
    1. Trouble-free document sharing
      5m 38s
    2. Emailing a document
      4m 4s
    3. Saving a document to a Windows Live drive
      4m 8s
    4. Saving to SharePoint and sharing a document link
      3m 59s
    5. Using Word on the web
      3m 4s
    6. Blogging with a document
      4m 27s
    7. Finalizing and password-protecting a document
      3m 38s
    8. Restricting editing for all or part of a document
      6m 3s
    9. Digitally signing a document
      5m 55s
  15. 25m 18s
    1. Changing Word options
      5m 42s
    2. Customizing the Ribbon
      7m 22s
    3. Creating and playing a macro
      8m 8s
    4. Assigning a macro to the Ribbon
      4m 6s
  16. 31s
    1. Goodbye
      31s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now "Already a member? Log in

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Word 2010 Essential Training.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.