View Single Post
 
Old 05-02-2022, 08:58 AM
eduzs eduzs is offline Windows 10 Office 2019
Expert
 
Join Date: May 2017
Posts: 266
eduzs is on a distinguished road
Default Replace only non-italic occurrences.

I need to replace some words, but not italic ones, this code does not works:
(It is replacing all occurrences, even in italic)
Code:
For x = 0 To UBound(TxtF)
 With .Range.Find
  .Text = TxtF(x)
  .Replacement.Text = TxtS(x)
  .Format = True
  .Font.Italic = False
  .MatchWholeWord = False
  .MatchCase = True
  .Execute Replace:=wdReplaceAll
 End With
Next x
Any ideas to fix this?
Thanks

Ps. SORRY using vba breakpoints I found that the problem was elsewhere in the code.
__________________
Backup your original file before doing any modification.

Last edited by eduzs; 05-02-2022 at 03:13 PM.
Reply With Quote