Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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 | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I modify the standard color palette in Word 2003? | Microsoft Word Help | |||
Word 2003 can't modify all table formats | Tables | |||
Client's laptop shuts down when she tries to modify any table in Word 2003 | Microsoft Word Help | |||
Modify layout of address book entry in Word 2003 | Microsoft Word Help | |||
Word 2003 - Modify Page Setup problem | Page Layout |