Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-16-2018, 06:34 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

Ok, I found a simple option to turn off auto numbering in the first macro. That should troubleshoot the problem you described above shouldn't it?

And I also found out that the macro is working way better when I write .Text = "(?@>)" instead of .Text = ""
Because now i dont have whole pages formatted bold or italic.

The only Problem left now is that the second macro does not find and replace words that are tagged with capitalized tags like <B>.
(I actually dont know why the first macro is giving out some capitalized tags, but I think that must be the styles/formatting of the old documents).
I tried to add .MatchCase = False to the second macro, but it makes no difference.

I really overreached my knowledge cap right now and ranning out of ideas... would be so great if you could help me!

The current to macros look like the following (I marked the passages red that I recently added on my own):

Code:
Sub aaaaaQuelldok()
' hyphenation off
ActiveDocument.AutoHyphenation = False
' auto numbering off
ActiveDocument.Range.ListFormat.ConvertNumbersToText
'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
Application.ScreenUpdating = True
End Sub
Code:
Sub aaaaaZieldok()
Application.ScreenUpdating = False
With ActiveDocument.Range.Find
  .ClearFormatting
  .Replacement.ClearFormatting
  .Format = True
  .Forward = True
  .MatchWildcards = True
.MatchCase = False
  .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

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 11:25 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