A
April
MS Word 2003
I have a template that uses macros to put continuation header fields on the
pages. (I've included a sample macro below.) This template uses 7 outline
levels, and two of those levels have different types (for instance "Level 2
TOC" and "Level 2 Text"). When the continuation headers are applied, they
look for the appropriate text styles and then append the one from the level
above to create the string. These continuation headers are applied by user
selection (they're not automatic). This results in something like 25
different menu selections, based on how the user formats the steps before the
continuation header they want to insert.
I'm wondering if there is a way to use just 7 different macros. One for
Level 1, one for all forms of Level 2, one for all forms of Level 3, etc. Any
ideas?
Outline levels (with continuation header examples):
Lev 1 (ex: 5.0)
Lev 2 TOC (ex: 5.1)
Lev 2 (ex: 5.1)
Lev 2 Act (ex: 5.1)
Lev 2 Txt (ex: 5.1)
Lev 3 TOC (ex: 5.1.1)
Lev 3 (ex: 5.1.1)
Lev Prereq (ex: 5.1.1)
Lev 4 (ex: 5.1.1.A)
Lev 5 (ex: 5.1.1.A.1)
Lev 6 (ex: 5.1.1.A.1.a)
Example macro:
Sub StepCont4()
'
' StepCont Macro
'Macro adds a page break and references the last heading 4 style
'
Selection.EndKey Unit:=wdLine
Selection.TypeParagraph
Selection.InsertBreak Type:=wdPageBreak
Selection.Style = ActiveDocument.Styles("Normal")
'This adds the field for finding the last heading 3
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, _
PreserveFormatting:=False
Selection.TypeBackspace
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.TypeText Text:="styleref \n ""heading 3"
Selection.EndKey Unit:=wdLine
'This adds a separator of .
Selection.TypeText Text:="."
'This adds the field for finding the last heading 4
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, _
PreserveFormatting:=False
Selection.TypeBackspace
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.TypeText Text:="styleref \n ""heading 4"
Selection.EndKey Unit:=wdLine
'This adds the words for continued
Selection.TypeText Text:=" (Continued)"
Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
'This toggles and updates the codes
Selection.Fields.ToggleShowCodes
Selection.Fields.Update
Selection.EndKey Unit:=wdLine
End Sub
I have a template that uses macros to put continuation header fields on the
pages. (I've included a sample macro below.) This template uses 7 outline
levels, and two of those levels have different types (for instance "Level 2
TOC" and "Level 2 Text"). When the continuation headers are applied, they
look for the appropriate text styles and then append the one from the level
above to create the string. These continuation headers are applied by user
selection (they're not automatic). This results in something like 25
different menu selections, based on how the user formats the steps before the
continuation header they want to insert.
I'm wondering if there is a way to use just 7 different macros. One for
Level 1, one for all forms of Level 2, one for all forms of Level 3, etc. Any
ideas?
Outline levels (with continuation header examples):
Lev 1 (ex: 5.0)
Lev 2 TOC (ex: 5.1)
Lev 2 (ex: 5.1)
Lev 2 Act (ex: 5.1)
Lev 2 Txt (ex: 5.1)
Lev 3 TOC (ex: 5.1.1)
Lev 3 (ex: 5.1.1)
Lev Prereq (ex: 5.1.1)
Lev 4 (ex: 5.1.1.A)
Lev 5 (ex: 5.1.1.A.1)
Lev 6 (ex: 5.1.1.A.1.a)
Example macro:
Sub StepCont4()
'
' StepCont Macro
'Macro adds a page break and references the last heading 4 style
'
Selection.EndKey Unit:=wdLine
Selection.TypeParagraph
Selection.InsertBreak Type:=wdPageBreak
Selection.Style = ActiveDocument.Styles("Normal")
'This adds the field for finding the last heading 3
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, _
PreserveFormatting:=False
Selection.TypeBackspace
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.TypeText Text:="styleref \n ""heading 3"
Selection.EndKey Unit:=wdLine
'This adds a separator of .
Selection.TypeText Text:="."
'This adds the field for finding the last heading 4
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, _
PreserveFormatting:=False
Selection.TypeBackspace
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.TypeText Text:="styleref \n ""heading 4"
Selection.EndKey Unit:=wdLine
'This adds the words for continued
Selection.TypeText Text:=" (Continued)"
Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
'This toggles and updates the codes
Selection.Fields.ToggleShowCodes
Selection.Fields.Update
Selection.EndKey Unit:=wdLine
End Sub