Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 03-14-2024, 11:27 AM
gmaxey gmaxey is offline VBA IF Statement Help Windows 10 VBA IF Statement Help Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,602
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

I think this will get you close:

Sub MarkPunct()
Application.ScreenUpdating = False
Dim oRng As Range
Set oRng = ActiveDocument.Range
With oRng.Find
.ClearFormatting
.Replacement.ClearFormatting
.Replacement.Highlight = True 'Activate replacement highlighting
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchWildcards = True
Options.DefaultHighlightColorIndex = wdPink
.Text = Chr(34) & "*" & Chr(34)
While .Execute
If oRng.Characters(2).Font.Bold = False Then oRng.Characters(1).HighlightColorIndex = wdPink
If oRng.Characters.Last.Previous.Font.Bold = False Then oRng.Characters.Last.HighlightColorIndex = wdPink
If oRng.Characters.First.Font.Bold = False And oRng.Characters(2).Font.Bold = True Then oRng.Characters.First.HighlightColorIndex = wdPink
If oRng.Characters.Last.Font.Bold = False And oRng.Characters.Last.Previous.Font.Bold = True Then oRng.Characters.Last.HighlightColorIndex = wdPink
Wend
End With
Set oRng = ActiveDocument.Range
With oRng.Find
.Text = "[" & Chr(145) & Chr(146) & Chr(147) & Chr(148) & "]"
.MatchWildcards = True
.Replacement.Highlight = True
.Font.Bold = False
.Execute Replace:=wdReplaceAll
End With
Set oRng = ActiveDocument.Range
With oRng.Find
.Text = "[" & Chr(44) & Chr(145) & Chr(146) & Chr(147) & Chr(148) & "\(\)\[\]\:\;\.\'\,]"
.MatchWildcards = True
.Replacement.Highlight = True
.Font.Bold = True
.Execute Replace:=wdReplaceAll
End With
Set oRng = ActiveDocument.Range
With oRng.Find
.Text = "[" & Chr(39) & Chr(146) & "]" 'Highlight bold curly quotes/apostrophes, brackets/square brackets, comma etc.
.MatchWildcards = True
.Font.Bold = True
While .Execute
If oRng.Characters.First.Previous.Font.Bold And oRng.Characters.Last.Next.Font.Bold Then
oRng.HighlightColorIndex = wdNoHighlight
End If
Wend
End With
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/

Last edited by gmaxey; 03-15-2024 at 08:01 AM.
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA IF Statement Help IF Statement (again) teza2k06 Excel 8 02-11-2022 08:41 AM
Converting a Select statement in Excel to an update statement shabbaranks Excel Programming 5 10-31-2018 11:47 PM
VBA IF Statement Help Need a little help with an if statement cangelis Excel 2 04-08-2015 05:55 PM
VBA IF Statement Help If statement, may be? Tony Singh Excel 6 03-04-2015 12:52 PM
VBA IF Statement Help Need help with If, Then Statement Please cangelis Excel 4 01-03-2014 09:10 AM

Other Forums: Access Forums

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