D
Designingsally
Hi
i want the macros to skip inserting THE before TABLE. is it possible?
Thanks in advance
Sally
if the macros were to search this sample data
UNO
ROCK
ROLLING
TABLE
ROLL
RAMS
Code is
Sub TheBeforeAcronym()
Dim myRange As Range
Dim orng As Range
Dim rslt As VbMsgBoxResult
Set myRange = ActiveDocument.Range
With myRange.FInd
..Text = "<([A-Z]{3,})>"
..MatchWildcards = True
..Wrap = wdFindStop
..Forward = True
While .Execute
myRange.Select
Set orng = myRange.Duplicate
orng.Move wdCharacter, -5
orng.MoveEnd wdCharacter, 4
If Not orng.Text = "the " Then
rslt = Msgbox(Prompt:="Add 'the' before this acronym?",
Buttons:=vbYesNoCancel)
If rslt = vbCancel Then Exit Sub
If rslt = vbYes Then
Selection.InsertBefore "the "
myRange.Collapse wdCollapseEnd
End If
End If
myRange.Collapse wdCollapseEnd
Wend
End With
Set myRange = Nothing
End Sub
i want the macros to skip inserting THE before TABLE. is it possible?
Thanks in advance
Sally
if the macros were to search this sample data
UNO
ROCK
ROLLING
TABLE
ROLL
RAMS
Code is
Sub TheBeforeAcronym()
Dim myRange As Range
Dim orng As Range
Dim rslt As VbMsgBoxResult
Set myRange = ActiveDocument.Range
With myRange.FInd
..Text = "<([A-Z]{3,})>"
..MatchWildcards = True
..Wrap = wdFindStop
..Forward = True
While .Execute
myRange.Select
Set orng = myRange.Duplicate
orng.Move wdCharacter, -5
orng.MoveEnd wdCharacter, 4
If Not orng.Text = "the " Then
rslt = Msgbox(Prompt:="Add 'the' before this acronym?",
Buttons:=vbYesNoCancel)
If rslt = vbCancel Then Exit Sub
If rslt = vbYes Then
Selection.InsertBefore "the "
myRange.Collapse wdCollapseEnd
End If
End If
myRange.Collapse wdCollapseEnd
Wend
End With
Set myRange = Nothing
End Sub