From: andreas on 13 May 2010 14:05 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 13 May 2010 15:59 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 14 May 2010 10:26 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
|
Pages: 1 Prev: Will Macros Work in Windows 7? Next: Readability statistics - VBA Code |