View Single Post
 
Old 11-29-2019, 10:30 AM
thiagoafdoria thiagoafdoria is offline Windows 10 Office 2019
Novice
 
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