Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 11-29-2019, 10:30 AM
thiagoafdoria thiagoafdoria is offline Changing words with bold and italics and turning "regular" words into italicized and bold ones Windows 10 Changing words with bold and italics and turning "regular" words into italicized and bold ones Office 2019
Novice
Changing words with bold and italics and turning "regular" words into italicized and bold ones
 
Join Date: Feb 2017
Posts: 18
thiagoafdoria is on a distinguished road
Default

Hi,
macropod, I'm sorry. I understood that you had suggested that I continue the discussion on that other thread; my mistake. I found some codes there but initially I couldn't understand them. However, after some trial and error I took advantage of one of the codes you posted and now I can transform make each bold word be between two asterisks (word -> **word**) and each italicized word to be between two underlines (italics -> __italics__). In case of anyone interested, that's the macro I'm using:

Code:
Sub Demo1 ( )
Application.ScreenUpdating = False
With ActiveDocument.Range.Find
  .ClearFormatting
  .Replacement.ClearFormatting
  .Format = True
  .Forward = True
  .MatchWildcards = True
  .Wrap = wdFindContinue
  .Font.Bold = True
  .Replacement.Text = "**^&**"
  .Execute Replace:=wdReplaceAll
  .ClearFormatting
  .Font.Italic = True
  .Replacement.Text = "__^&__"
  .Execute Replace:=wdReplaceAll
End With
Application.ScreenUpdating = True
End Sub
To do the opposite, I've tried the following:

Code:
Sub Demo 2 ( )
Application.ScreenUpdating = False
With ActiveDocument.Range.Find
  .ClearFormatting
  .Replacement.ClearFormatting
  .Format = True
  .Forward = True
  .MatchWildcards = True
  .Wrap = wdFindContinue
  .Replacement.Text = "\1"
  .Text = "\**(*)\**"
  .Replacement.Font.Bold = True
  .Execute Replace:=wdReplaceAll
  .Replacement.ClearFormatting
  .Text = "\__(*)\__"
  .Replacement.Font.Italic = True
  .Execute Replace:=wdReplaceAll
End With
Application.ScreenUpdating = True
End Sub
It does work for italics, but not for bold. Any ideas of how to make it work for bold too?

Thank's!
Reply With Quote
 

Tags
bold, italics, macro



Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing words with bold and italics and turning "regular" words into italicized and bold ones All words in document appear bold but are not! Ezra Word 4 07-31-2017 06:53 AM
Changing words with bold and italics and turning "regular" words into italicized and bold ones Bold & Italics NOT turning off with keyboard shortcuts Tweaker Word 6 08-26-2015 03:07 PM
remove repeated words with " macro " or " wild cards " in texts with parentheses and commas jocke321 Word VBA 2 12-10-2014 11:27 AM
Changing words with bold and italics and turning "regular" words into italicized and bold ones Is there a way to use "find/replace" to find italics words? slayda Word 3 09-14-2011 02:16 PM
Changing words with bold and italics and turning "regular" words into italicized and bold ones Making Multiple Words Bold mtk989 Word 2 06-25-2011 11:27 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:42 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