Macro to format part of Company name

M

marcia

I am trying to setup a macro to find and change part of the company name to
italics. For example, the company name is HotPotato; all one word, but Potato
is supposed to be italicized. I have setup AutoText for when I type in the
name myself, but many times, I receive a document from someone else in the
company and need to ensure that the name is formatted correctly. So far I
haven't been successful with any macros that I have tried. Any suggestions?
IS there a better way to do this?

I am using Office 2003; won't be switching to 2007 for a few months
(probably run into this issue again).

Thank you for any help you might be able to give me.
 
G

Greg Maxey

Sub ScratchMacro()
Dim oRng As Word.Range
Set oRng = ActiveDocument.Range
With oRng.Find
.Text = "HotPotato"
While .Execute
oRng.MoveStart wdCharacter, 3
oRng.Font.Italic = True
oRng.Collapse wdCollapseEnd
Wend
End With
End Sub
 
M

marcia

Thanks, this really helped.

--
marcia


Greg Maxey said:
Sub ScratchMacro()
Dim oRng As Word.Range
Set oRng = ActiveDocument.Range
With oRng.Find
.Text = "HotPotato"
While .Execute
oRng.MoveStart wdCharacter, 3
oRng.Font.Italic = True
oRng.Collapse wdCollapseEnd
Wend
End With
End Sub
 
M

marcia

Thank you, I had already tried that but it didn't work on pages of text that
I had to pickup from someone else. It did work entries that I was typing.

--
marcia


Suzanne S. Barnhill said:
You might find it easier to add a formatted AutoCorrect entry.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top