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 / November 2005

Tip: Looking for answers? Try searching our database.

Search for text in the header?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Roger Marrs - 22 Nov 2005 22:17 GMT
I would like to perform a search and replace for text in the header of an
active document as well as in the body of the active document.  I can
perform the search and replace without any problem if the text is body, but
I can't figure out how to use VBA to search the header.

I tried using the macro recorder hoping that would capture the necessary
information, but I couldn't get the macro to function properly using the
information gather from that process.

Here is the code I use to search the body of the document:

Selection.HomeKey Unit:=wdStory
   Selection.Find.ClearFormatting
   Selection.Find.Replacement.ClearFormatting
   With Selection.Find
       .Text = "-*"
       .Replacement.Text = "-"
       .Forward = True
       .Wrap = wdFindContinue
       .Format = False
       .MatchCase = False
       .MatchWholeWord = False
       .MatchWildcards = False
       .MatchSoundsLike = False
       .MatchAllWordForms = False
   End With
   Selection.Find.Execute Replace:=wdReplaceAll

I suppose I could delete several of those parameters and the macro would
still work fine.

Thanks in advance for any assistance searching the header.

Roger Marrs
Roger Marrs - 22 Nov 2005 22:40 GMT
I thought I'd cancelled this post to the group.  Now that I've sent the post
again, I see I didn't cancel the message and it posted to the group.  Please
disregard this posting as I'm a little more precise in what I'm trying to
accomplish.

Roger
> I would like to perform a search and replace for text in the header of an
> active document as well as in the body of the active document.  I can
[quoted text clipped - 30 lines]
>
> Roger Marrs

Rate this thread:






 
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.