Format text between two styles
I am beginner in vba hoping for some guidelines to automate my daily task. So, any help would be greatly appreciated.
Here is my code
Sub find_and_format()
Dim doc As Document
Dim rng As Range
Set doc = Application.ActiveDocument
Set rng = doc.Content
With rng.find
.ClearFormatting
.Text = "Answer"
.Style = ActiveDocument.Styles("ans")
.Format = False
.MatchAllWordForms = False
.MatchWildcards = False
.MatchCase = False
.Wrap = wdFindContinue
End With
Do Until rng.find.Execute = False
Selection.MoveDown unit:=wdParagraph, Count:=1
Selection.Style = ActiveDocument.Styles("t")
Selection.MoveDown unit:=wdParagraph, Count:=1
'do while manual numbering is found
Do While Selection.Range.ListFormat.ListType = wdListSimpleNumbering
' and then i want to select and change the autonumbering to manual numbering
Selection.Range.ListFormat.ConvertNumbersToText
Selection.Style = ActiveDocument.Styles("tt")
' or repeat this process until another style is found
Loop
'can i access the range between a style to another style and then format it??
Loop
'i have attached a sample file
End Sub
|