Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-02-2022, 08:58 AM
eduzs eduzs is offline Replace only non-italic occurrences. Windows 10 Replace only non-italic occurrences. Office 2019
Expert
Replace only non-italic occurrences.
 
Join Date: May 2017
Posts: 262
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
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
"Find and Replace" tool leaves out many of the occurrences of what I put in the "find" window Swarup Word 8 06-24-2021 08:31 PM
Macro to format all occurrences of a text in a table Dzib Word VBA 11 08-05-2019 11:24 PM
Replace only non-italic occurrences. Variable text field code based on occurrences on each page Cosmo Word 2 12-29-2015 11:54 AM
how to italic the word with vba tomlam Excel Programming 1 02-03-2014 07:09 PM
Replace only non-italic occurrences. Replace all occurrences of one merge field with plain text blankenthorst Mail Merge 5 07-01-2011 05:18 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:31 AM.


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