Editing Macros: Fear Not
PC Magazine , November, 2002
You`ve used Microsoft Word`s Macro Recorder to create a great macro, but it doesn`t
quite work the way you intended. Or perhaps you need to extend the capabilities
of a favorite macro. You may think that the solution is to record the macro anew.
But there`s a better way”the Visual Basic Editor that ships with Word. This is a
great way to create or edit macros, but many people assume that they lack the requisite
knowledge and that horrible things can happen (like Word refusing to run) if you
incorrectly edit a macro`s programming code.
In this article we`ll explain how to use the VB Editor safely to edit a macro,
without any programming knowledge. We`ll ease into this brave new world by using
Word`s Macro Recorder to create two simple macros, which we will then edit in the
VB Editor.
Safety First
Word macros are stored in templates. You probably store yours in Normal.dot,
the default template Word uses for all documents. A corrupted template can cause
Word to misbehave”or stop functioning entirely”so it`s a good idea to make a backup
copy of your template before you do any substantial macro editing.
To save templates safely, first close Word if it is open and then use File |
Save As to create a copy of Normal.dot with another filename. We copied Normal.dot
to Normal.001 the first time we edited it, then Normal.002, and so forth. Using
the date in the filename can also be useful. Such naming strategies provide a trail
of fallback versions if they are needed.
Creating the Basic Macros
Let`s say you have a set of documents you want to use for a client presentation,
but you want to make them uniform. It is extremely tedious to go into each document
and change the various elements, but macros can turn this into a quick and easy
project. You start by recording a macro to change the fonts. Create a test document
to work with, then start the Macro Recorder with Tools | Macro | Record New Macro
and name the macro Client1. Now select the entire document with Edit | Select All
and convert all text to the Arial typeface by selecting Arial from the drop-down
Font list on the Formatting toolbar. If you`re using Word 2002, you may think you`re
finished, but there is one more step: Select Arial from the nearby drop-down Style
menu.
Next, record another macro named Copyright, which inserts a Word page footer
containing a copyright notice into your documents. Begin recording, select View
| Header and Footer, and click on the Switch Between Header and Footer button in
the toolbar that appears. Type some text for your footer and click the Close button.
Inside the Macros
We now have two macros, Client1() and Copyright(). Let`s take a look at them
in the VB Editor. Select Tools | Macro | Macros, and in the dialog box that appears,
select the Client1 macro name and click the Edit button. The document that appears
actually contains all of the macros you`ve created.
Macros are in fact Visual Basic subroutines. A macro begins with a line containing
the word Sub, the macro`s name, and parentheses, as in Sub Client1(); it ends with
the statement End Sub. Everything in between is the code that does the nitty-gritty
work of the macro.
Take a look at Figures 1 and 2, which show the Word 2000 and Word 2002 versions
of Client1(), respectively. Both versions include unnecessary code that we can delete.
In the Word 2000 version, it`s easy to figure out what you can delete: A bug causes
the Macro Recorder to insert the following line twice.
Selection Font.Name = "Arial"
You need only one such line, so delete the other. As always, be careful when
deleting or adding lines, making sure that each line of the resulting code remains
on its own line. When satisfied, select Save | Normal in the VB Editor, return to
the Word window, and check your macro on a test document.
The Word 2002 version of Client1() contains a lot more code, because Word recorded
all elements of the states you changed when you selected from the Font and Style
pick lists, so you need to do a bit more sleuthing to determine what you can delete.
We want to keep the Selection.WholeStory, which selects the entire document. But
the lines between the first With Selection.Font and its corresponding End With have
nothing to do with changing to the Arial font and thus can be deleted. The only
line related to our goal occurs in the second With Selection.Font section: .NameAscii
= "Arial". You can delete all the other lines in that section. The result should
look like this:
Sub Client1() ` ` Client1 Macro ` Macro recorded 08/21/02 by J. W. Olsen ` Selection.WholeStory
With Selection.Font .NameAscii = "Arial" End With End Sub
How do you know what you can edit safely? To a large extent, this comes with
experience and experimentation. But as in examples here, duplicate code may be wasted
code, cluttering and slowing down a macro. Entire chunks of code, in fact (such
as the With End With block in the Word 2002 macro), may show no apparent connection
to the desired goal of a macro and thus are candidates to test for deletion. You
can comment a line out first to see what happens. And as long as you`ve saved backup
versions, you can feel free to experiment.
Robert`s Runes Font 2.0
Robert`s RUNES Fonts are a complete 26 character runic alphabet. There are over
10 different style rune alphabets. Robert`s RUNES are based on the Futhark and the
Elder Futhark runes. The runes are an ancient alphabet that has been used for magic
and other purposes throughout the ages. Now you can write your own rune scrolls,
parchments, poster lettering, websiteheadings, etc.
Visit homepage of Robert`s
Runes Font
Project index
- Extensis Launches Suitcase Fusion ” the Future of Font Management; Suit
- Modifying Font Size
- Embedding Fonts in Web Pages
- ORGANIZE/PRINT FONT LIBRARY WITH PRINTER`S APPRENTICE 7.5
- Pounds 79,000 cathedral font drawing found in barrow
- Samsung Licenses Font Fusion from Bitstream - Samsung Electronics Company L
- Bitstream offers small, fast font rendering subsystem for Symbian OS mo
- News: New font CD from Linotype - Linotype Library GmbH FontExplorer font lib
- Font Box 2.6 gains speed, gets a face lift - Insider Software`s font man
- Jose Rivera-Font
- The font pirates vs. Adobe: A victory for the good guys - Print Clearly - Com
- Font problems when editing PDFs
- Font problems in Acrobat 6
- Trouble with Typefaces, The
- Are Your Bills Piling Up?
- A Font of Information.
- FontAgent Pro Gets Improved Font Handling
- Random access: have you been burned by fearful technology companies? - Professi
- Font Reserve to hit Version 2 - DiamondSoft`s Font Reserve 2.0 - Product Announcement
- DEVANAGARI FONT
- Martin Stein joins Extensis as Senior Product Manager; Seasoned Apple and Q
- Extensis Ships Suitcase and Font Reserve Plug-ins for Adobe InDesign CS2;
- Microsoft`s Font Foibles
- Your Ph.D. in Fonts - using fonts in marketing materials and business correspond
- Up Front: Fixing a defiled font file
- Cave Painting, Font-de-Gaume.(Brief Article)(Poem)
- Monotype Imaging Releases the Monotype Library, OpenType Edition; Product Incl
- Buyer`s Guide: True to type: A `handwritten` font
- Font packages for Windows - Bitstream`s FaceLift and Adobe Systems` Adobe
- A mammoth mystery: was accuracy sacrificed to romance in the Museum`s m
- Take a Test with FlashQuiz
- Editing Macros: Fear Not
- Bitstream Receives Chinese Government Approval for GB18030 Font
- ProHelp works font and form magic on AS/400. (ProHelp Systems` FontMagic
- The best ways to enhance your desktop-publishing system - utility progra
- Digest: News from Designorati, Insider Software, Code Line, Monotype Imaging
- Solutions for 3 Common PDF Problems
- Adventures in TrueType - typefaces
- Font piracy: another view. (response to Chuck Byrne, Print, March/April 1994)
- Create: what`s in a font?(Secrets)(OpenType)(related article: Stream flas
- The family stone. (font designs developed by Sumner Stone)
- Dead History. (computer font)
- Corel Partners With Bitstream To Provide Next-Generation Font Support For Li
- Baptismal font, Sobata, Negev desert - fourth century - Illustration
- Font vs. typeface
- MyFonts Awarded U.S. Patent
- Font Viewer 1.3
- xp font viewer 2.2
- Free&Easy Font Viewer 1.2
- Font utility 28.03
- Advanced Fonts Viewer 1.8
- Free&Easy Font Viewer 1.2
- FontsShow 2.0
- X-Fonter 6.1
- Advanced Font Viewer 3.1
- Font viewer free for use 11.05
- FontView 1.1
- Free&Easy Font Viewer 1.2
- Fonter viewer 2.3
- Font viewer free for use 11.05
- xp font viewer 2.2
- Font Viewer 1.3
- xp font viewer 2.2
- FontPage 2.0.6
- FontReview 2.6
- Fast Font Set 1.10
- Font Viewer 1.3
- FontsShow 2.0
- Font Viewer 1.3
- Advanced Font Viewer 3.1
- X-Fonter 6.1
- Wondershare Video to Zune Converter
- FontsShow 2.0
- Typograf 4.8f
- IDAutomation UPC EAN Barcode Fonts 6.08
- fontVW Fontviewer 1.0
- TexterFlex 2.0
- ABC Amber SVG Converter 1.03
- FontViewer 1.2.3
- FontMap 2.33
- MainType 2.0
- ASCII 1.1
- FontTAB 1.3
- Advanced Font Viewer review
- Free&Easy Fonts Viewer review
- Diary Book (Upgraded) 1.5
- Free&Easy Font Viewer review
- Font Printer 2.5
- FontViewer 1.2.3
- Font Printer 2.5
- Font Namer 2.5
- Advanced Font Viewer 3.1
|