Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-13-2018, 03:20 PM
macropod's Avatar
macropod macropod is offline VBA Find&Replace all bold, itlaic, underlined and highlighted words/characters Windows 7 64bit VBA Find&Replace all bold, itlaic, underlined and highlighted words/characters Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,375
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

I am unable to replicate the behaviour you say is occurring when I run the macros against your 'VBA Example' attachment. And just to make sure, I added:
ActiveDocument.Range.Font.Reset


to the end of the first macro to strip out all character-level formatting (Paragraph Style formatting remains formatted as such).
Quote:
Originally Posted by Kalü View Post
Where is your Donate-Button? I would like to give you some tip for your great help!!
We don't have one; all help here is gratis.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #2  
Old 04-16-2018, 04:54 AM
Kalü Kalü is offline VBA Find&Replace all bold, itlaic, underlined and highlighted words/characters Windows 10 VBA Find&Replace all bold, itlaic, underlined and highlighted words/characters Office 2010 32bit
Advanced Beginner
VBA Find&Replace all bold, itlaic, underlined and highlighted words/characters
 
Join Date: Apr 2018
Posts: 43
Kalü is on a distinguished road
Default

Well thats weird because I still have the problem (please see in the attached document: 1.1 is highlighted).

Could it be that I added "ActiveDocument.Range.Font.Reset" at the wrong place in the macro? My first macro now looks like this:
Code:
Sub aaaaaQuelldok()
' hyphenation off
ActiveDocument.AutoHyphenation = False
'tag all formatted words
Application.ScreenUpdating = False
With ActiveDocument.Range.Find
  .ClearFormatting
  .Replacement.ClearFormatting
  .Format = True
  .Forward = True
  .MatchWildcards = True
  .Wrap = wdFindContinue
  .Font.Underline = True
  .Text = ""
  .Replacement.Text = "<u>^&</u>"
  .Execute Replace:=wdReplaceAll
  .ClearFormatting
  .Highlight = True
  .Replacement.Text = "<h>^&</h>"
  .Execute Replace:=wdReplaceAll
  .ClearFormatting
  .Font.Bold = True
  .Replacement.Text = "<b>^&</b>"
  .Execute Replace:=wdReplaceAll
  .ClearFormatting
  .Font.Italic = True
  .Replacement.Text = "<i>^&</i>"
  .Execute Replace:=wdReplaceAll
End With
ActiveDocument.Range.Font.Reset
Application.ScreenUpdating = True
End Sub
and just to complete the second macro looks like this:
Code:
Sub aaaaaZieldok()
Application.ScreenUpdating = False
With ActiveDocument.Range.Find
  .ClearFormatting
  .Replacement.ClearFormatting
  .Format = True
  .Forward = True
  .MatchWildcards = True
  .Wrap = wdFindContinue
  .Replacement.Text = "\1"
  .Text = "\<u\>(*)\</u\>"
  .Replacement.Font.Underline = True
  .Execute Replace:=wdReplaceAll
  .Replacement.ClearFormatting
  .Text = "\<h\>(*)\</h\>"
  .Replacement.Highlight = True
  .Execute Replace:=wdReplaceAll
  .Replacement.ClearFormatting
  .Text = "\<b\>(*)\</b\>"
  .Replacement.Font.Bold = True
  .Execute Replace:=wdReplaceAll
  .Replacement.ClearFormatting
  .Text = "\<i\>(*)\</i\>"
  .Replacement.Font.Italic = True
  .Execute Replace:=wdReplaceAll
End With
Application.ScreenUpdating = True
End Sub
Attached Files
File Type: docx After running second Macro.docx (55.7 KB, 12 views)
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA Find&amp;Replace all bold, itlaic, underlined and highlighted words/characters Macro to find and replace headings in bold and underline redzan Word VBA 4 02-13-2016 12:24 PM
VBA Find&amp;Replace all bold, itlaic, underlined and highlighted words/characters Find, select, and replace part of text with bold paik1002 Word VBA 4 12-07-2015 11:24 PM
VBA Find&amp;Replace all bold, itlaic, underlined and highlighted words/characters Find and Replace some characters with Bullets kjxavier Word 1 01-02-2015 12:15 AM
VBA Find&amp;Replace all bold, itlaic, underlined and highlighted words/characters Find/Replace Wildcard Needed-Bold & Highlight rsrasc Word VBA 3 11-11-2014 03:55 PM
VBA Find&amp;Replace all bold, itlaic, underlined and highlighted words/characters find and replace in bold redzan Word VBA 1 07-27-2014 03:35 PM

Other Forums: Access Forums

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


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