PC Review


Reply
Thread Tools Rate Thread

How to create a macro to format a set of words in Word 2003?

 
 
Debbie in Plano
Guest
Posts: n/a
 
      14th Feb 2008
I would like to create a macro to thick underline all the coomon helping
verbs in a document. I can do this manually as follows (sorry this is so
wordy ... I wrote it for a friend who doesn't have a techie bone in her body):

Open the “Find and Replace” window (ctrl-H or Edit/Replace).

If the “Less” button is showing, continue to the next step; otherwise,
press the “More” button so that all options are visible.

Complete the window as follows:

Find what:
Type “be” (without the quotes) in the “Find what” text box.

Replace with:
Select the field by clicking the mouse inside the “Replace
with:” text box.

Press the Format button.
Select Font / Underline Style / thick underline … or
whatever formatting you want.

Search:
Checkmark “Find all word forms”

Then press the “Replace All” button.

You then have to repeat the replace, substituting the words "have", "do",
"may", "can", "shall", and "will" in the find text box. This procedure will
put a thick underline under all the common helping verbs.

However, if I record these steps as a macro and run the macro, then the
found words are replaced with null (deleted) instead of being underlined.
Here is the macro produced when I did the steps above for the forms of "be":

Sub Mark_Helping_Verbs()
'
' Mark_Helping_Verbs Macro
' Macro recorded 2/13/2008 by HP Authorized Customer
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "be"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Replacement.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub


Does anyone know how to fix the macro so that it will underline the found
words instead of deleting them? Or maybe there is a different/better way to
do this?

Thanks,
Debbie


 
Reply With Quote
 
 
 
 
Patrick Keenan
Guest
Posts: n/a
 
      14th Feb 2008
"Debbie in Plano" <(E-Mail Removed)> wrote in message
news:BFBB7F23-E985-42C3-9AC6-(E-Mail Removed)...
>I would like to create a macro to thick underline all the coomon helping
> verbs in a document. I can do this manually as follows (sorry this is so
> wordy ... I wrote it for a friend who doesn't have a techie bone in her
> body):
> <snippage>
> Does anyone know how to fix the macro so that it will underline the found
> words instead of deleting them? Or maybe there is a different/better way
> to
> do this?


Debbie,
You'll probably have better results asking this in an Office or
Word-specific newsgroup.

But, it looks like you've specified that the replacement text is "", which
pretty much tells the macro to delete the word it found.

You may need to store the word in a variable and specify the variable as the
replacement text.

HTH
-pk

 
Reply With Quote
 
Debbie in Plano
Guest
Posts: n/a
 
      14th Feb 2008
Figured it out ... adding the following fixes the problem:

.Replacement.Style = True
.Replacement.Font.Underline = wdUnderlineThick

 
Reply With Quote
 
Debbie in Plano
Guest
Posts: n/a
 
      14th Feb 2008
Aargghh ... only ".Replacement.Font.Underline = wdUnderlineThick" is needed;
the .Replacement.Style will change the paragraph style.

Now I have a happy macro.

"Debbie in Plano" wrote:

> Figured it out ... adding the following fixes the problem:
>
> .Replacement.Style = True
> .Replacement.Font.Underline = wdUnderlineThick
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I create Macro Button using Word 2003 normsta Microsoft Word Document Management 5 18th Mar 2010 12:36 PM
Word 97 Macro to Create Outlook '03 Email With Text Format John Ciccone Microsoft Outlook VBA Programming 1 5th May 2008 09:42 PM
Create a macro to eliminate certain words from several columns Jorge Microsoft Excel Worksheet Functions 4 16th Jan 2008 08:15 PM
Can I create a Word Macro in an ASCII text format? =?Utf-8?B?RGVubmlzIFAu?= Microsoft Word Document Management 3 14th Sep 2006 03:06 PM
Word 2003 - create a macro with a pause in it. =?Utf-8?B?S2F0aWUgU21pdGg=?= Microsoft Word Document Management 1 1st Dec 2004 09:30 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:29 AM.