![]() |
#1
|
|||
|
|||
![]()
Hi,
Document contains this text: 1 Now a Green Text 2 Label this in Black 3 Soft Kitty 4 Dog owners are great. 5 Spelling is not my forte 6 Measure Twice 7 Distance Measure The following code will find 1st instance of the yellow text and Cut/Paste it to a new document. On the second loop it crashes at Selection.Range.Paste with Object empty error. Not sure what the issue is. Likely that I am quite new to VBA and Word docs. Any help would be appreciated. Sub FindYellowText() Dim oResponse As Document Selection.HomeKey wdStory With Selection.Find .ClearFormatting .Replacement.ClearFormatting .Text = "" .MatchWildcards = False .Forward = True .Wrap = wdFindStop .Font.ColorIndex = wdYellow .Execute Do Until Not .Found If Selection.Range.Font.ColorIndex = wdYellow Then Selection.Range.Cut Set oResponse = Documents.Add With oResponse Selection.Range.Paste End With End If .Execute Loop End With End Sub |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
gasparik | Word VBA | 1 | 05-11-2020 05:41 AM |
![]() |
RET | Word | 1 | 05-02-2016 07:28 PM |
![]() |
userman | Word | 2 | 09-26-2012 01:52 AM |
not showing colored text from external emails | MasterGator | Outlook | 0 | 01-31-2012 02:20 PM |
Making text boxes with colored bar at the top | daviddoria | PowerPoint | 0 | 08-30-2009 03:19 PM |