Beginner question

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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
jamesski@xxxxxxxxx
http://www.jlsce.com

.



Relevant Pages

  • Re: Beginner question
    ... The error occurs on the CurrPane.Selection.GoTo, not on the With DoSearch. ... run the macro by putting the cursor in the code in the VBA ... I'm searching for yellow highlighting and want to simply remove it. ... CurrPane.Selection.GoTo wdGoToLine, wdGoToFirst ...
    (microsoft.public.word.vba.beginners)
  • Re: Beginner question
    ... "Jay Freedman" wrote in message ... run the macro by putting the cursor in the code in the VBA ... I'm searching for yellow highlighting and want to simply remove it. ... CurrPane.Selection.GoTo wdGoToLine, wdGoToFirst ...
    (microsoft.public.word.vba.beginners)
  • Re: Macro to show/hide rows
    ... send your worksheet to me (remove the obvious stuff from my email ... Is it highlighting a line of code when it displays the message? ... put a breakpoint on the first line of my code ... Also when I plugged in that macro I'm getting an error '1004'. ...
    (microsoft.public.excel.programming)
  • Re: Highlight New Data from Web Table Import
    ... you would need a macro. ... Microsoft MVP Excel ... "Don Guillett" wrote: ... > un-do the highlighting for the next time the table gets updated, ...
    (microsoft.public.excel.misc)
  • Re: Word Form Fields & Macros
    ... Thank you for your suggestions Jay. ... Everywhere in the code that you see a line with red highlighting, ... ' Macro created 2006-Sep-26 by Linda Sgabellone ... Within the first row of form fields, there are three columns, each ...
    (microsoft.public.word.vba.general)