From: andreas on
Dear Experts:

I did some highlighting in a document using different colors (wdYellow
and wdBlue).

I now would like to delete all words/characters that have been
highlighed yellow and leave the blue ones alone.

How can I achieve this using a VBA code?

Help is much appreciated. Thank you very much in advance.

Regards, Andreas
From: Jay Freedman on
You can use this:

Sub DeleteYellowHighlightedText()
Dim oRg As Range
Set oRg = ActiveDocument.Range
With oRg.Find
.Text = ""
.Format = True
.Highlight = True
.Forward = True
While .Execute
If oRg.HighlightColorIndex = wdYellow Then
oRg.Delete
End If
oRg.Collapse wdCollapseEnd
Wend
End With
End Sub

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

andreas wrote:
> Dear Experts:
>
> I did some highlighting in a document using different colors (wdYellow
> and wdBlue).
>
> I now would like to delete all words/characters that have been
> highlighed yellow and leave the blue ones alone.
>
> How can I achieve this using a VBA code?
>
> Help is much appreciated. Thank you very much in advance.
>
> Regards, Andreas


From: andreas on
On 13 Mai, 21:59, "Jay Freedman" <jay.freed...(a)verizon.net> wrote:
> You can use this:
>
> Sub DeleteYellowHighlightedText()
>     Dim oRg As Range
>     Set oRg = ActiveDocument.Range
>     With oRg.Find
>         .Text = ""
>         .Format = True
>         .Highlight = True
>         .Forward = True
>         While .Execute
>             If oRg.HighlightColorIndex = wdYellow Then
>                 oRg.Delete
>             End If
>             oRg.Collapse wdCollapseEnd
>         Wend
>     End With
> End Sub
>
> --
> Regards,
> Jay Freedman
> Microsoft Word MVP        FAQ:http://word.mvps.org
> Email cannot be acknowledged; please post all follow-ups to the newsgroup so
> all may benefit.
>
>
>
> andreas wrote:
> > Dear Experts:
>
> > I did some highlighting in a document using different colors (wdYellow
> > and wdBlue).
>
> > I now would like to delete all words/characters that have been
> > highlighed yellow and leave the blue ones alone.
>
> > How can I achieve this using a VBA code?
>
> > Help is much appreciated. Thank you very much in advance.
>
> > Regards, Andreas- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -

Hi Jay,

this did the trick. Great help from your side. Thank you very much.
Regards, Andreas