View Single Post
 
Old 05-26-2018, 12:50 AM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

I'm not a fan of the selection object and I would think you need to be explicit in settintg the direction of the search. There also seems to be a flaw with the No Proofing not catching the first word if it is immediately preceded by a bracket. Try this variation
Code:
Sub MarkParenthesizedItalicsNoProofing()
  Dim aRng As Range, aSubRng As Range
  Set aRng = ActiveDocument.Range
  With aRng.Find
    .ClearFormatting
    .Text = "\([A-Z][a-z.]@[!\)]@\)"
    .MatchWildcards = True
    .Forward = True
    .Wrap = False
    Do While .Execute
      Set aSubRng = ActiveDocument.Range(aRng.Start + 1, aRng.End - 1)
      aRng.NoProofing = aSubRng.Italic = True
      aRng.Collapse wdCollapseEnd
    Loop
  End With
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote