Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 08-02-2022, 10:30 AM
karkey karkey is offline find and replace with format Windows 10 find and replace with format Office 2013
Novice
find and replace with format
 
Join Date: Jan 2021
Posts: 19
karkey is on a distinguished road
Default find and replace with format

While replace I need to italic and highlight the word (et^sal).

Code:
Sub etalnew()
  Dim rngStory As Range
  For Each rngStory In ActiveDocument.StoryRanges
    
    Options.DefaultHighlightColorIndex = wdDarkYellow
    Selection.Find.Replacement.Highlight = True
    
    With rngStory.Find
      .Text = "<et al>"
      .Replacement.Text = "et^sal"
      .Replacement.Highlight = True
      .Wrap = wdFindContinue
      .MatchWildcards = True
      .Execute Replace:=wdReplaceAll
    End With
  Next rngStory
End Sub


Last edited by macropod; 08-02-2022 at 02:54 PM. Reason: Added code tags to restore formatting
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
find and replace with format find/replace date format improvement? LQuinn Word VBA 2 05-14-2021 11:15 PM
Find/Replace using format of cell catflap Excel 1 09-11-2017 07:28 AM
find and replace with format Find and Replace maintain format winningson Word 3 01-19-2013 05:38 AM
find and replace with format Find and Replace Format macro issue Jack Word VBA 2 12-12-2012 09:24 PM
find and replace with format 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:39 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