Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-08-2023, 06:41 AM
gmaxey gmaxey is offline Check uniform font size in each paragraph Windows 10 Check uniform font size in each paragraph Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,636
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Flag them as italic or bold or whatever then apply the appropriate character style and remove the flags.




Code:
Sub ScratchMacro()
'A basic Word Macro coded by Gregory K. Maxey
Dim oRng As Range
Dim oPar As Paragraph
  Set oRng = ActiveDocument.Range
  With oRng.Find
    .Font.Bold = True
    While .Execute
      oRng.Text = "<b>" & oRng.Text & "</b>"
      oRng.Collapse wdCollapseEnd
    Wend
  End With
  Set oRng = ActiveDocument.Range
  With oRng.Find
    .Font.Italic = True
    While .Execute
      oRng.Text = "<i>" & oRng.Text & "</i>"
      oRng.Collapse wdCollapseEnd
    Wend
  End With
  ActiveDocument.Range.Font.Reset
  For Each oPar In ActiveDocument.Paragraphs
    oPar.Style = "Body Text"
  Next
  Set oRng = ActiveDocument.Range
  With oRng.Find
    .Text = "(\<i\>\<b\>)(*)(\</b\>\</i\>)"
    .Replacement.Text = "\2"
    .Replacement.Style = "Emphasis"
    .MatchWildcards = True
    .Execute Replace:=wdReplaceAll
  End With
  Set oRng = ActiveDocument.Range
  With oRng.Find
    .Text = "(\<i\>)(*)(\</i\>)"
    .Replacement.Text = "\2"
    .Replacement.Style = "Subtle Emphasis"
    .MatchWildcards = True
    .Execute Replace:=wdReplaceAll
  End With
  Set oRng = ActiveDocument.Range
  With oRng.Find
    .Text = "(\<b\>)(*)(\</b\>)"
    .Replacement.Text = "\2"
    .Replacement.Style = "Strong"
    .MatchWildcards = True
    .Execute Replace:=wdReplaceAll
  End With
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Check uniform font size in each paragraph VBA - Word how to globally change the font and font size in footnotes thomasoj Word VBA 3 01-15-2020 06:26 AM
Check uniform font size in each paragraph Merging two Word documents: 2nd document not maintaining original font type and font size Swarup Word 31 08-28-2018 06:55 PM
Font size showing different (some superscripted??) but tools show its the same size? mikkygee PowerPoint 4 12-14-2015 11:21 PM
Check uniform font size in each paragraph Looping Macro to Change Font, Font Size, and Give Heading 1 WH7262 Word VBA 1 08-26-2014 03:46 PM
Check uniform font size in each paragraph Paragraph (carriage) return font size revrossreddick Word 2 12-28-2011 01:33 PM

Other Forums: Access Forums

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