Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / June 2005

Tip: Looking for answers? Try searching our database.

Brain dead

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JLenihan - 08 Jun 2005 14:48 GMT
I am working with this macro to have it look through a document for all
italic text and wraps it with <I> and <I*>. If I run it as is, it doesn't do
anything so I am surious what code I put in the find area?

Any help is appreciated

Jerry

Sub ReplItalic()
'
' Replace italic text
' '
   Selection.Find.ClearFormatting
   Selection.Find.Replacement.ClearFormatting
   With Selection.Find
       .Text = ""
       .Replacement.Text = "<I>^&<I*>"
       .Forward = True
       .Wrap = wdFindContinue
       .Format = True
       .MatchCase = False
       .MatchWholeWord = False
       .MatchWildcards = False
       .MatchSoundsLike = False
       .MatchAllWordForms = False
   End With
   Selection.Find.Execute Replace:=wdReplaceAll
End Sub
Dave Lett - 08 Jun 2005 15:39 GMT
Hi Jerry,

You can use the following:

Sub ReplItalic()
'
' Replace italic text
' '
   Selection.Find.ClearFormatting
   Selection.Find.Replacement.ClearFormatting
   With Selection.Find
       .Text = "<*>"
       .Font.Italic = True
       .Replacement.Text = "<I>^&<I*>"
       .Forward = True
       .Wrap = wdFindContinue
       .Format = True
       .MatchCase = False
       .MatchWholeWord = False
       .MatchWildcards = True
       .MatchSoundsLike = False
       .MatchAllWordForms = False
   End With
   Selection.Find.Execute Replace:=wdReplaceAll
End Sub

Notice that I changed the .Text parameter (find what) and set the
.MatchWildcards parameter to True.

HTH,
Dave

>I am working with this macro to have it look through a document for all
> italic text and wraps it with <I> and <I*>. If I run it as is, it doesn't
[quoted text clipped - 25 lines]
>    Selection.Find.Execute Replace:=wdReplaceAll
> End Sub
J Lenihan - 08 Jun 2005 16:06 GMT
Thanks! Definiately an improvement. The only thing I noticed is that if a
sentence or paragraph is italic it will do each word seperately. Can it find
the beginning and ending of an italic phrase rather than the individual words?

thanks again

> Hi Jerry,
>
[quoted text clipped - 57 lines]
> >    Selection.Find.Execute Replace:=wdReplaceAll
> > End Sub
Greg Maxey - 08 Jun 2005 16:53 GMT
Try:

Sub ReplItalic()
Dim oRng As Word.Range
Set oRng = ActiveDocument.Range
With oRng.Find
 .ClearFormatting
 .Replacement.ClearFormatting
 .Font.Italic = True
 .Replacement.Text = "<I>^&<I*>"
 .Forward = True
 .Wrap = wdFindContinue
 .Format = True
 .MatchCase = False
 .MatchWholeWord = False
 .MatchSoundsLike = False
 .MatchAllWordForms = False
 .Execute Replace:=wdReplaceAll
End With
End Sub

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> Thanks! Definiately an improvement. The only thing I noticed is that
> if a sentence or paragraph is italic it will do each word seperately.
[quoted text clipped - 64 lines]
>>>    Selection.Find.Execute Replace:=wdReplaceAll
>>> End Sub
Helmut Weber - 08 Jun 2005 19:11 GMT
Hi J,

... and I'd suggest to clear all paragraph marks
from any formatting beforehand. Otherwise you might
run into trouble, depending on how you want to process
the output of all the replacing further on.

And take care of removing italic from the replacement
text, so that more runs of your macro don't
result in <I><I><I>some text<I*><I*><I*>

Greetings from Bavaria, Germany

Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.