S
Sahana
I m trying to add - after word "pre"
Technically, macros should not check for pre-defined. As - is added
after pre. But macros I m trying to execute is checking for pre-
defined also.
Can someone tell me where I m going wrong?
Code is
Sub PRELhyphen()
Dim oRng As Range
Set oRng = ActiveDocument.Range
With oRng
With .FInd
.ClearFormatting
.Replacement.ClearFormatting
Do While .Execute("pre-[A-Za-z]{1,}>", MatchWildcards:=True)
oRng.Select
Select Case Msgbox(Chr(34) & "pre" & Chr(34) & " on page " &
Selection.Information(wdActiveEndPageNumber) & " should be followed by
a hyphen. Please refer to the dictionary for clarification.",
vbYesNoCancel, "Pre")
Case vbCancel
Exit Sub
Case vbYes
oRng = Replace(oRng.Text, "pre-", "pre")
End Select
oRng.Collapse wdCollapseEnd
Loop
End With
End With
End Sub
Technically, macros should not check for pre-defined. As - is added
after pre. But macros I m trying to execute is checking for pre-
defined also.
Can someone tell me where I m going wrong?
Code is
Sub PRELhyphen()
Dim oRng As Range
Set oRng = ActiveDocument.Range
With oRng
With .FInd
.ClearFormatting
.Replacement.ClearFormatting
Do While .Execute("pre-[A-Za-z]{1,}>", MatchWildcards:=True)
oRng.Select
Select Case Msgbox(Chr(34) & "pre" & Chr(34) & " on page " &
Selection.Information(wdActiveEndPageNumber) & " should be followed by
a hyphen. Please refer to the dictionary for clarification.",
vbYesNoCancel, "Pre")
Case vbCancel
Exit Sub
Case vbYes
oRng = Replace(oRng.Text, "pre-", "pre")
End Select
oRng.Collapse wdCollapseEnd
Loop
End With
End With
End Sub