D
Designingsally
i m trying to deleted em dashes ( Ctrl plus -) when it is prefixed with the
word "pre" in a document.
For example, Pre-amble. The macros ll correct it as Preamble.
Sub UMPre()
Dim oRng As Range
Set oRng = ActiveDocument.Range
With oRng
With .FInd
.ClearFormatting
.Replacement.ClearFormatting
Do While .Execute("Pre(" & ChrW(8212) & ")[a-z]{1,}>",
MatchWildcards:=True)
oRng.Select 'Word processing
Select Case Msgbox(Chr(34) & "Pre-" & Chr(34) & " on page " &
Selection.Information(wdActiveEndPageNumber) & " should not be" & Chr(34) &
"hyphenated." & Chr(34), vbYesNoCancel, "Colon")
Case vbCancel
Exit Sub
Case vbYes
oRng = Replace(oRng.Text, "(" & ChrW(8212) & ")", "")
If oRng.Words.Last.Characters.First.Case <> wdUpperCase Then
oRng.Font.Bold = False
oRng.Words.First.Bold = True
oRng.Words.Last.Characters.First.Case = wdUpperCase
End If
End Select
oRng.Collapse wdCollapseEnd
Loop
End With
End With
End Sub
I wrote the macro code. But it is not identifying em dashes at all what
could be the reason for this. Can someone explain?
Pls take a look the code given below.
Thanks for the help in advance.
word "pre" in a document.
For example, Pre-amble. The macros ll correct it as Preamble.
Sub UMPre()
Dim oRng As Range
Set oRng = ActiveDocument.Range
With oRng
With .FInd
.ClearFormatting
.Replacement.ClearFormatting
Do While .Execute("Pre(" & ChrW(8212) & ")[a-z]{1,}>",
MatchWildcards:=True)
oRng.Select 'Word processing
Select Case Msgbox(Chr(34) & "Pre-" & Chr(34) & " on page " &
Selection.Information(wdActiveEndPageNumber) & " should not be" & Chr(34) &
"hyphenated." & Chr(34), vbYesNoCancel, "Colon")
Case vbCancel
Exit Sub
Case vbYes
oRng = Replace(oRng.Text, "(" & ChrW(8212) & ")", "")
If oRng.Words.Last.Characters.First.Case <> wdUpperCase Then
oRng.Font.Bold = False
oRng.Words.First.Bold = True
oRng.Words.Last.Characters.First.Case = wdUpperCase
End If
End Select
oRng.Collapse wdCollapseEnd
Loop
End With
End With
End Sub
I wrote the macro code. But it is not identifying em dashes at all what
could be the reason for this. Can someone explain?
Pls take a look the code given below.
Thanks for the help in advance.