Epinions.com 
Join Epinions | Learn More! | Sign In   

HomeMember CenterThings to Know About Epinions.com

Read Advice   Write an essay on this topic. 

Using MS Word Macros To Add HTML Tags to Your Reviews

May 07 '04

The Bottom Line If you write your review in Microsoft Word, here's a quick method for adding HTML tags that will consistently pass muster in the submission process.

Many authors here at Epinions regularly incorporate HTML tags into their work as a means of lending visual interest to text with bold-face and italic type, or to hyperlink to other pertinent information. Many of these same authors have learned – usually the “hard” way – not to create draft reviews within the submission window, but to compose the text in a WYSIWYG (What You See Is What You Get) word processor; this is very often Microsoft Word. I know I do, on both counts: navigation is easier in a word processor, and the included spell checking software is vastly superior to that in the submission window, especially the suggestion feature. Even the Grammar Curmudgeon ocassionally spells words wrong!

The combination of these two practices has great potential, but can also lead to problems when MS Word gets its grimy paws on your text, especially on those bits of text that constitute HTML tags. As pointed out by mobiprof and by me on separate occasions (see, tGC does know how to spell that word), Word’s “labor-saving devices” like Smart Quotes and Smart Correction can often cause misery when you’re trying to type an HTML tag set. On the other hand, a different Word labor-saving device can make your life oh! so much easier. I’m talking about Macros.


”Eeeeew! Macros!” You Say

Hey, it’s not really all that hard – I’ll walk you through the process in a minute.

What I’ve done is create three macros (they’re automatically stored in Word) that spit out the most common sets of tags – hyperlinks, bold, and italics – ready for me to just stick in the text. I’ll be typing along and decide to put a word in bold-face, so I hit my pre-assigned hot key and presto! The letters <b></b> appear, ready for me to type the chosen text right there between the > and the <. I have a second hot key for italics and a third for the <a tagset to create hyperlinks. The beauty of the macro approach is that Smart Correction never messes with the text, so it doesn’t randomly capitalize the letter I or convert double quote marks into left- and right-quotes, probably the single most common cause of frustration for would-be HTML users on the site. Assuming that you’ve created your tags without any included spaces, the macros will never put any troublesome spaces inside the angle brackets, either.

So. You ready to try your hand at creating a macro? Let’s do it!


Macro 1: Italics

(Note: I’m writing this in MS Word 2002, but I’ve created macros like this in Word 2000 and in Word 97. The process has not, in my memory, changed from version to version.)

From the Tools menu, choose Macro and then click on Record New Macro…. The resulting window says Record Macro and lets you specify four attributes: a macro name (I called mine “Itags”), where to store it (default works fine), a description (if you want) and whether to put it on a toolbar or use a keyboard shortcut. I use a keyboard shortcut, so click on the keyboard icon.

Decide on an easily-remembered keyboard combination (you’ll have to press all keys simultaneously) and press the keys. Your combination will appear in the space labeled “Press New Shortcut Key.” If that combination of keys is already assigned to some other task, it’ll tell you “Currently assigned to…” For instance, the combination control-C (which shows up as Ctrl+C) is currently assigned to Edit-Copy. Try not to overwrite a vital function – if it looks as though you’ll do so, backspace will delete your combination and you can try again. Once you’ve found a combination you can use, hit the “Assign” button. You can then either press “Close” or assign a second (and third…) hotkey combination to this tag.

Once you’ve pressed “Close,” the recorder starts. You’ll see a small, two-button toolbar appear on your screen – this is the “recorder.” You want your macro to “play back” the keystrokes that make the tags for italics, so type the following characters without spaces. DO NOT COPY AND PASTE THIS TEXT!!! You have no idea what happens on the clipboard:

<i></i>

When those seven characters are done, click the square stop button on the recorder. You’re done. Test the macro by typing your hotkey – the string above should automagically appear on the page. Warning: do not use an uppercase i in either position, much less one and not the other.


Macro 2: Bold-Face

The only difference between the italics and bold-face tagsets is substitution of the letter b for i. Repeat the process that was outlined above, assigning a different name and hotkey to the macro. The keystrokes you will record this time are (without spaces!):

<b></b>

Again, don’t use uppercase letters. Test your macro’s function to see that the correct string of characters appears.


Macro 3: Hyperlinks

Hyperlinks get people into a lot of trouble because of those pesky quotation marks. Using a macro, however, avoids having your hyperlink text attacked by the SmartQuotes engine.

To create a hyperlink tagset, repeat the process outlined in the first section, assigning a different name and hotkey to your third macro. This time, you’ll record the following keystrokes in your macro:

<a href=""></a>

Note that there is a single space between the letters a and h, and no other spaces. Once more, don’t use uppercase letters, and test to see that the complete and correct string appears when you enter the hotkey combination..


Using the Macros

When you reach a point where you want to italicize or bold a word or paste in a hyperlink, simply press the hotkey combination and the string will appear. Place the cursor between the tags (>here<) and type in the words you want. A URL can be pasted into the space between the quote marks ("here"). You can even click on the space inside a tagset and paste in another – the perfect way to italicize linked book titles (All Hat) or to both bold and italicize a word.


Recovering from a Goof

If you mess up your macro, don’t despair – they can be deleted from the Macros… choice under Tools / Macro. Just highlight the bad one and then click “Delete.”


Other Problems

Another of Word’s “labor-saving” devices automatically puts spaces around any text that you paste – instead of type – into your macro-generated tagsets. This is no big deal in a medium where the extra space is usually hard to see, as demonstrated here , though it tends to look a little funny if there are underlined spaces around a hyperlink, as demonstrated here .

If you plan to paste a copied URL into the link, copy the link from the address bar on your browser or from the “Properties” panel of the browser. If you copy an actual link – underlined – then the same smart correction feature will add spaces inside the href="" bits, and that will not work.


Choosing Hot Keys

I picked combinations that are easy to remember, but in doing so I had to overwrite some function of Word (I forget which). The combinations I used are Ctrl+Alt+i for italics, Ctrl+Alt+b for bold, and Ctrl+Alt+a for the hyperlink tags. Use whatever you want – if you write lots of reviews, you’ll soon have your hotkeys committed to memory.

Happy macroing.

 Read all comments (26)
 Write your own comment
scmrak

Epinions.com ID:
scmrak
scmrak is a Lead on Epinions in Cars & Motorsports
scmrak is an Advisor on Epinions in Books
scmrak is a Top Reviewer on Epinions in Home and Garden, Hotels & Travel, Books
Epinions Most Popular Authors - Top 50
Location: ~240000E, 3300000N UTM15
Reviews written: 1358
Trusted by: 411 members
About Me:
It's been real, y'all.


Help | Member Center | Message Boards | Site Rules | User Agreement | Privacy Policy | Site Index | Topic Index  
About Epinions | Careers | Contact Epinions | Advertising  

Epinions | Shopping.com | Rent.com | Free Classifieds | Price Comparison UK

Shopping.com Network © 1999-2009 Shopping.com, Inc. Trademark Notice

Epinions.com periodically updates pricing and product information from third-party sources,
so some information may be slightly out-of-date. You should confirm all information before relying on it.