![]() |
|
#1
|
|||
|
|||
|
If the document exists the style leave else need to create the character style.
after that can create more style like this. Code:
Sub CStyle()
Dim objDoc As Document
Dim cbolditalic As Style
Set objDoc = ActiveDocument
Set cbolditalic = ActiveDocument.Styles.Add("*italic", Type:=WdStyleType.wdStyleTypeCharacter)
With cbolditalic.Font
.Name = "Times New Roman"
.Bold = False
.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 = False
.Font.italic = True
.Font.Subscript = False
.Font.Superscript = False
.Replacement.Style = "*italic"
.Replacement.Highlight = True
.Execute Replace:=wdReplaceAll
End With
End With
Next rngStory
Application.ScreenUpdating = True
End Sub
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Styles: Cannot Apply or Save | Justin | Word | 5 | 11-01-2020 03:20 PM |
| Macro to apply Normal dot styles | John9210 | Word VBA | 2 | 06-07-2018 05:15 PM |
| Apply styles in word table | 1van | Word VBA | 2 | 11-17-2015 11:05 AM |
| search for special character and apply outline? | n00bie-n00b | Word VBA | 0 | 10-12-2014 03:17 AM |
| automatically extract footnotes into new file and apply character format to footnote | hrdwa | Word | 0 | 02-27-2010 03:16 AM |