Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #7  
Old 05-26-2018, 12:50 AM
Guessed's Avatar
Guessed Guessed is online now VBA Find inexplicably aborts & goes to top Windows 10 VBA Find inexplicably aborts & goes to top 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
 

Tags
vba find and replace



Similar Threads
Thread Thread Starter Forum Replies Last Post
find IP in range / find number between numbers gn28 Excel 4 06-14-2015 03:46 PM
VBA Find inexplicably aborts & goes to top Find where find text contains a double quote norgro Word VBA 1 01-23-2015 10:58 PM
VBA Find inexplicably aborts & goes to top Find what box in Find and replace limits the length of a search term Hoxton118 Word VBA 7 06-10-2014 05:05 AM
VBA Find inexplicably aborts & goes to top Macro that can find phrase and then find another and copy jperez84 Word VBA 10 09-19-2012 04:48 PM
VBA Find inexplicably aborts & goes to top Bad view when using Find and Find & Replace - Word places found string on top line paulkaye Word 4 12-06-2011 11:05 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:26 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft