J
Jim Szatkowski
I'm using Word 2003 on a Vista Business box. I've tried to duplicate a
macro shown in VBA for Dummies 4th Edition to remove highlighting of text.
I'm searching for yellow highlighting and want to simply remove it. Where
have I gone wrong - I keep getting a 91 error regarding the line "With
DoSearch" at top of repeated code section.
Macro follows:===================================================
Public Sub RemoveHighlight()
'
' RemoveHighlight Macro
Dim CurrPane As Pane
' ActiveDocument.ActiveWindow.View = wdNormalView
CurrPane.Selection.GoTo wdGoToLine, wdGoToFirst
Dim DoSearch As Find
Set DoSearch = CurrPane.Selection.Find
With DoSearch
.ClearFormatting
.Highlight = True
.MatchCase = False
While DoSearch.Execute()
With CurrPane.Selection.FormattedText
If .HighlightColorIndex = wdYellow Then
.HighlightColorIndex = wdNoHighlight
End If
End With
Wend
CurrPane.Selection.GoTo wdGoToLine, wdGoToFirst
End With
End Sub
=======================================
Thanks!
Jim
James L Szatkowski, PE, NSPE
(e-mail address removed)
http://www.jlsce.com
macro shown in VBA for Dummies 4th Edition to remove highlighting of text.
I'm searching for yellow highlighting and want to simply remove it. Where
have I gone wrong - I keep getting a 91 error regarding the line "With
DoSearch" at top of repeated code section.
Macro follows:===================================================
Public Sub RemoveHighlight()
'
' RemoveHighlight Macro
Dim CurrPane As Pane
' ActiveDocument.ActiveWindow.View = wdNormalView
CurrPane.Selection.GoTo wdGoToLine, wdGoToFirst
Dim DoSearch As Find
Set DoSearch = CurrPane.Selection.Find
With DoSearch
.ClearFormatting
.Highlight = True
.MatchCase = False
While DoSearch.Execute()
With CurrPane.Selection.FormattedText
If .HighlightColorIndex = wdYellow Then
.HighlightColorIndex = wdNoHighlight
End If
End With
Wend
CurrPane.Selection.GoTo wdGoToLine, wdGoToFirst
End With
End Sub
=======================================
Thanks!
Jim
James L Szatkowski, PE, NSPE
(e-mail address removed)
http://www.jlsce.com