Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
Tith Tith is offline
external usenet poster
 
Posts: 5
Default vba Word 2003 modify headers

I have a macro to run through the document and change all my red text to
blue, but it doesn't affect my headers. How do I get it to incorporate my
headers as well?

Public Sub Red2Blue()
With ActiveDocument.Content.Find
.ClearFormatting
.Font.Color = wdColorRed
With .Replacement
.ClearFormatting
.Font.Color = wdColorBlue
End With

.Execute FindText:="", ReplaceWith:="", Format:=True,
Replace:=wdReplaceAll
End With
End Sub
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Greg Maxey[_2_] Greg Maxey[_2_] is offline
external usenet poster
 
Posts: 668
Default vba Word 2003 modify headers

Unlike the UI Find and Replace operations, your code is only processing the
main text storyrange of the document. At the very least you would need to
interate through the three different header storyranges. This still
wouldn't pick up text in the footers, textboxes, comments, and other
storyranges.

See: http://gregmaxey.mvps.org/VBA_Find_And_Replace.htm

Tith wrote:
I have a macro to run through the document and change all my red text
to blue, but it doesn't affect my headers. How do I get it to
incorporate my headers as well?

Public Sub Red2Blue()
With ActiveDocument.Content.Find
.ClearFormatting
.Font.Color = wdColorRed
With .Replacement
.ClearFormatting
.Font.Color = wdColorBlue
End With

.Execute FindText:="", ReplaceWith:="", Format:=True,
Replace:=wdReplaceAll
End With
End Sub



  #3   Report Post  
Posted to microsoft.public.word.docmanagement
Greg Maxey[_2_] Greg Maxey[_2_] is offline
external usenet poster
 
Posts: 668
Default vba Word 2003 modify headers

Unlike the UI Find and Replace operations, your code is only processing the
main text storyrange of the document. At the very least you would need to
interate through the three different header storyranges. This still
wouldn't pick up text in the footers, textboxes, comments, and other
storyranges.

See: http://gregmaxey.mvps.org/VBA_Find_And_Replace.htm

Tith wrote:
I have a macro to run through the document and change all my red text
to blue, but it doesn't affect my headers. How do I get it to
incorporate my headers as well?

Public Sub Red2Blue()
With ActiveDocument.Content.Find
.ClearFormatting
.Font.Color = wdColorRed
With .Replacement
.ClearFormatting
.Font.Color = wdColorBlue
End With

.Execute FindText:="", ReplaceWith:="", Format:=True,
Replace:=wdReplaceAll
End With
End Sub



  #4   Report Post  
Posted to microsoft.public.word.docmanagement
Tith Tith is offline
external usenet poster
 
Posts: 5
Default vba Word 2003 modify headers

Public Sub Red2Blue()
' Replace the headers Text from Red to Blue

Set MyStoryRange = ActiveDocument.StoryRanges(wdPrimaryHeaderStory)
Do Until MyStoryRange Is Nothing

With MyStoryRange.Find
.ClearFormatting
.Font.Color = wdColorRed
With .Replacement
.ClearFormatting
.Font.Color = wdColorBlue
End With

.Execute FindText:="", ReplaceWith:="", Format:=True,
Replace:=wdReplaceAll
End With

Set MyStoryRange = MyStoryRange.NextStoryRange
Loop

' Replace the body Text from Red to Blue
With ActiveDocument.Content.Find
.ClearFormatting
.Font.Color = wdColorRed
With .Replacement
.ClearFormatting
.Font.Color = wdColorBlue
End With

.Execute FindText:="", ReplaceWith:="", Format:=True,
Replace:=wdReplaceAll
End With
End Sub

"Tith" wrote:

I have a macro to run through the document and change all my red text to
blue, but it doesn't affect my headers. How do I get it to incorporate my
headers as well?

Public Sub Red2Blue()
With ActiveDocument.Content.Find
.ClearFormatting
.Font.Color = wdColorRed
With .Replacement
.ClearFormatting
.Font.Color = wdColorBlue
End With

.Execute FindText:="", ReplaceWith:="", Format:=True,
Replace:=wdReplaceAll
End With
End Sub

  #5   Report Post  
Posted to microsoft.public.word.docmanagement
Tith Tith is offline
external usenet poster
 
Posts: 5
Default vba Word 2003 modify headers

Public Sub Red2Blue()
' Replace the headers Text from Red to Blue

Set MyStoryRange = ActiveDocument.StoryRanges(wdPrimaryHeaderStory)
Do Until MyStoryRange Is Nothing

With MyStoryRange.Find
.ClearFormatting
.Font.Color = wdColorRed
With .Replacement
.ClearFormatting
.Font.Color = wdColorBlue
End With

.Execute FindText:="", ReplaceWith:="", Format:=True,
Replace:=wdReplaceAll
End With

Set MyStoryRange = MyStoryRange.NextStoryRange
Loop

' Replace the body Text from Red to Blue
With ActiveDocument.Content.Find
.ClearFormatting
.Font.Color = wdColorRed
With .Replacement
.ClearFormatting
.Font.Color = wdColorBlue
End With

.Execute FindText:="", ReplaceWith:="", Format:=True,
Replace:=wdReplaceAll
End With
End Sub

"Tith" wrote:

I have a macro to run through the document and change all my red text to
blue, but it doesn't affect my headers. How do I get it to incorporate my
headers as well?

Public Sub Red2Blue()
With ActiveDocument.Content.Find
.ClearFormatting
.Font.Color = wdColorRed
With .Replacement
.ClearFormatting
.Font.Color = wdColorBlue
End With

.Execute FindText:="", ReplaceWith:="", Format:=True,
Replace:=wdReplaceAll
End With
End Sub

Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I modify the standard color palette in Word 2003? daisyankh Microsoft Word Help 2 December 12th 08 07:01 AM
Word 2003 can't modify all table formats Rich Tables 1 September 22nd 06 03:13 PM
Client's laptop shuts down when she tries to modify any table in Word 2003 [email protected] Microsoft Word Help 1 June 16th 06 03:44 PM
Modify layout of address book entry in Word 2003 Lynne S. Microsoft Word Help 1 January 18th 06 12:26 AM
Word 2003 - Modify Page Setup problem Bob Jennens Page Layout 3 December 5th 04 05:17 PM


All times are GMT +1. The time now is 07:20 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"