Chris Farrell Membership
AVG PC TuneUp
AVG AntiVirus Business Edition
This site uses cookies. By continuing to browse the site, you are agreeing to our use of cookies. Find out more.

How To Record A Macro Using Microsoft Word Part 3 (Video)

 Posted by  Add comments
 

How To Record A Macro Using Microsoft Word – Part 3
Editing a Macro Using The VBA Editor

Quil Macro

Introduction

Hi, my name is Philip King, and welcome to Part 3 of my tutorial on Recording A Macro Using Microsoft Word.

In this tutorial you’ll learn how to make changes to your macro using the Visual Basic for Applications (VBA) Editor.

 

This is the 3rd of a three part tutorial covering the recording of a macro using Microsoft Word, how to assign shortcut keys and toolbar buttons for the macro and how to make modifications to your macros.

  • Part 1: Recording a Macro
    Search and Replace all occurrences of a word or phrase in an open document.
  • Part 2: Creating Macro Shortcut Keys
    Assign a macro to a quick-key (shortcut) and a toolbar button so it can be run quickly.
  • Part 3: Editing a Macro
    How to edit and make changes to macro.

 

[Download]

This video tutorial, How To Record A Macro Using Microsoft Word Part 3,
is also available as a HD PDF file for download. You will need Adobe Acrobat 9 or better to view.

 

Why Use A Macro?

Why would you want an macro? Well there’s nothing quite like a macro for getting repetitive work done quickly and although creating macros can seem mysterious it’s really quite simple. So in this three part tutorial I’ll show you the basics of creating, running and changing a macro for Microsoft Word. For my demonstrations I’ll be using Word 2003 but the techniques I’ll show you can be used on any version of Microsoft Word.

The Next Step

In Part One you learned how to use the Macro Recorder to turn your keystrokes and mouse movements into a macro code. You also learned how to run the macro using the Tools > Macros menu command.

In Part Two, you learned how to assign a macro to a quick-key or keyboard shortcut and a toolbar button so the macro can be run easily and quickly.

So, continuing on from the last lesson, lets see how to modify our macro using the Visual Basic for Applications (VBA) Editor.

A Change Of Heart

Suppose you’ve had a change of heart and instead of changing, Old Company Name to, New Fantastic Company Name, you want the new name to be, Really Brilliant Company Name.

Does this mean all your previous time and effort creating a macro has been wasted? Not at all, there’s no need to re-create the original macro with the new text, instead, you can use the Visual Basic for Applications editor to modify the original macro.

Visual Basic for Applications

Now although the VBA editor is a complex programming tool, with a little care, everyone can use it to modify their macros without any problems. So lets get started and see how it’s done.

Open the document you are going to modify. To keep things simple when editing macros using the VBA editor only have the document you are editing open.

Open the VBA editor by clicking the Tools tab and selecting Macro from the menu, followed by the Macros menu item.

With the Macros dialog window open select the macro we are going to edit, ChangeCoName and click the Edit button. This action will open the Microsoft Visual Basic Editor window.

Edit as Normal

You can edit the text in the right-hand pane just the same as you would in Word or any Text editor. Much of the code shown in the editor window won’t make much sense unless you know VBA but you can probably guess what’s happening from the text.

As our macro is doing a Find and Replace we should be looking for text resembling that procedure. In this case Text = "Old Company Name" is obviously our find this text and Replacement.Text = "New Fantastic Company Name" the original new text.

Replacement Text

We want to insert the latest company name, so change New Fantastic Company Name, to Really Brilliant Company Name.

Use the Save Normal button to save the changes.

Close the VBA program and return to our Word document, and lets see if our changes work. You can press the Shortcut key combination or click the Macro Button we created in Part 2 or use the menu system to run the macro. I’m just going to click our Macro Button.

And the changes to our macro worked.

Not too difficult after all.

Congratulations

Congratulations, you’ve successfully edited and tested your first macro using VBA.

I hope you enjoyed this session. Don’t forget to let me have your thoughts on this video. See you soon.

You may also be interested in the following:


KingSolutions.org.uk is hosted on JustHost

 Leave a Reply

(required)

(required)

88 queries in 1.000 seconds (Child).