Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-31-2021, 09:33 PM
stky stky is offline highlight replacement format where is mistake Windows 10 highlight replacement format where is mistake Office 2013
Advanced Beginner
highlight replacement format where is mistake
 
Join Date: Apr 2021
Posts: 30
stky is on a distinguished road
Default highlight replacement format where is mistake

Sub boltitalic()

Dim objDoc As Document
Dim cboltitalic As Style
Set objDoc = ActiveDocument

Set cboltitalic = ActiveDocument.Styles.Add("*boltitalic", Type:=WdStyleType.wdStyleTypeCharacter)
Options.DefaultHighlightColorIndex = wdYellow
Selection.Find.ClearFormatting
With cboltitalic.Font
.Name = "Times New Roman"
.Bold = True
.Italic = True
.Subscript = False
.Superscript = False

End With

Dim rngStory As Range
For Each rngStory In ActiveDocument.StoryRanges

Application.ScreenUpdating = False
With ActiveDocument.Range
With rngStory.Find

.ClearFormatting
.Replacement.ClearFormatting
.text = "[!+\-\<\>]"
.Replacement.text = ""
.MatchWildcards = True
.Format = True
.Forward = True
.Wrap = wdFindContinue

.Font.Bold = True
.Font.Italic = True
.Font.Subscript = False
.Font.Superscript = False
.Replacement.Style = "*boltitalic"
Selection.Find.Replacement.ClearFormatting


Selection.Find.Replacement.Highlight = True
.Execute Replace:=wdReplaceAll


End With
End With
Next rngStory
Application.ScreenUpdating = True
End Sub
Reply With Quote
  #2  
Old 10-31-2021, 09:36 PM
gmayor's Avatar
gmayor gmayor is offline highlight replacement format where is mistake Windows 10 highlight replacement format where is mistake Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,106
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Is there a question here?
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 10-31-2021, 09:43 PM
stky stky is offline highlight replacement format where is mistake Windows 10 highlight replacement format where is mistake Office 2013
Advanced Beginner
highlight replacement format where is mistake
 
Join Date: Apr 2021
Posts: 30
stky is on a distinguished road
Default thanks mayor

I found the solution.

Sub boltitalic()

Dim objDoc As Document
Dim cboltitalic As Style
Set objDoc = ActiveDocument

Set cboltitalic = ActiveDocument.Styles.Add("*boltitalic", Type:=WdStyleType.wdStyleTypeCharacter)
With cboltitalic.Font
.Name = "Times New Roman"
.Bold = True
.Italic = True
.Subscript = False
.Superscript = False

End With

Dim rngStory As Range
For Each rngStory In ActiveDocument.StoryRanges

Application.ScreenUpdating = False
With ActiveDocument.Range
With rngStory.Find

Options.DefaultHighlightColorIndex = wdYellow
.ClearFormatting
.Replacement.ClearFormatting
.text = ""
.Replacement.text = ""
.MatchWildcards = True
.Format = True
.Forward = True
.Wrap = wdFindContinue

.Font.Bold = True
.Font.Italic = True
.Font.Subscript = False
.Font.Superscript = False
.Replacement.Style = "*boltitalic"
.Replacement.Highlight = True
.Execute Replace:=wdReplaceAll


End With
End With
Next rngStory
Application.ScreenUpdating = True
End Sub
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
I've set up sync with iCloud by mistake brissle Outlook 0 12-13-2014 01:02 PM
Huge Mistake! markg2 Excel 2 05-12-2014 08:05 AM
Made a mistake with a macro change lance_kidd Word 0 02-09-2011 06:36 PM
highlight replacement format where is mistake Initial Mistake simpson55 Outlook 2 02-02-2011 09:52 AM
find - reading highlight - highlight all / highlight doesn't stick when saved bobk544 Word 3 04-15-2009 03:31 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:52 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft