![]() |
#1
|
|||
|
|||
![]()
I'm trying to devise a code to apply a specific style if the fnt ref number followed by a return is preceded by specific characters. I need help with the if-condition. Thanks!
Code:
Sub FormatThese() Dim oRng As Range Set oRng = ActiveDocument.Range Do With oRng.Find .MatchWildcards = False .Text = "^f^p" 'find this sequence .Replacement.Text = "" .Wrap = wdFindStop .Execute End With 'oRng.Select 'If found and sequence preceded by one of these characters: "!.?-–»" Then 'If oRng.Find.Found And oRng.Characters.Last.Previous = "[!.?-–»]" Then If oRng.Find.Found Then oRng.Style = "myStyle" Else: Exit Do End If oRng.Collapse 0 Loop Set oRng = Nothing End Sub |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Add contents of specific cell into next column in range with specific string of characters | silverman166 | Excel | 5 | 02-08-2024 07:58 AM |
![]() |
mrwoggie | Word VBA | 1 | 01-18-2022 03:08 PM |
![]() |
Annie Wordy | Word VBA | 1 | 11-03-2017 08:36 PM |
My style keeps changing, can't get saved style to apply | Meenie50 | Word | 7 | 07-20-2017 03:47 PM |
How can I easily preceded the title of a saved Outlook Message with the date and number | Chris Waller | Outlook | 0 | 09-01-2016 12:45 PM |