Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #20  
Old 04-16-2018, 03:00 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,518
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

Your addition of:
(?@>)
to the first macro is unlikely to help; indeed it will produce masses of extra tags. If you're getting spurious tags somewhere, that's because you have spurious formatting in those locations.

It's also not the code I posted that is creating any capitalised tags. The only way I can envisage that happening is if you have existing content formatted with a Style using the 'All Caps' or 'Small Caps' attribute. As for adding:
.MatchCase = False
to the second macro, that won't work because it's doing a wildcard Find. Try:
Code:
Sub aabFettKursivQuelldok()
Application.ScreenUpdating = False
With ActiveDocument
  .AutoHyphenation = False
  With .Range
    .ListFormat.ConvertNumbersToText
    With .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
    .Style = wdStyleNormal
    .Font.Reset
    .HighlightColorIndex = wdNoHighlight
  End With
End With
Application.ScreenUpdating = True
End Sub
Code:
Sub aabFettKursivZieldok()
Application.ScreenUpdating = False
With ActiveDocument.Range.Find
  .ClearFormatting
  .Replacement.ClearFormatting
  .Format = True
  .Forward = True
  .MatchWildcards = True
  .Wrap = wdFindContinue
  .Replacement.Text = "\1"
  .Text = "\<[Uu]\>(*)\</[Uu]\>"
  .Replacement.Font.Underline = True
  .Execute Replace:=wdReplaceAll
  .Replacement.ClearFormatting
  .Text = "\<[Hh]\>(*)\</[Hh]\>"
  .Replacement.Highlight = True
  .Execute Replace:=wdReplaceAll
  .Replacement.ClearFormatting
  .Text = "\<[Bb]\>(*)\</[Bb]\>"
  .Replacement.Font.Bold = True
  .Execute Replace:=wdReplaceAll
  .Replacement.ClearFormatting
  .Text = "\<[Ii]\>(*)\</[Ii]\>"
  .Replacement.Font.Italic = True
  .Execute Replace:=wdReplaceAll
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 



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 05:40 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