Okay, so I'm working on the "1.1.X" header.
I create my header here:
VB Code:
Set oHeader1 = objDoc.Content.Paragraphs.Add With oHeader1 .Range.Text = STR_IOS_PAGE_NAME .Range.Font.AllCaps = True .Range.Underline = wdUnderlineThick .Range.ParagraphFormat.KeepWithNext = True .Range.ParagraphFormat.Alignment = wdAlignParagraphCenter .Range.Style = "Heading 3" .Range.ListFormat.ApplyNumberDefault 'e.g. 1. .Range.Font.Bold = True .Format.SpaceAfter = 24 '24 pt spacing after paragraph. .Range.InsertParagraphAfter .Range.Font.AllCaps = False .Range.ParagraphFormat.Alignment = wdAlignParagraphLeft .Range.ParagraphFormat.KeepWithNext = False End With
But then I took the VB code from Word here (I'm not taking all of it, just the one I need):
VB Code:
With ListGalleries(wdOutlineNumberGallery).ListTemplates(5).ListLevels(1) 'I only care about List Level 1 since Normal Text data will come after this. 'And, NumberFormat will be hardcoded since it will be merged into another larger document ' at section 3.1 .NumberFormat = "3.1.%1" .TrailingCharacter = wdTrailingTab .NumberStyle = wdListNumberStyleArabic .NumberPosition = InchesToPoints(0) .Alignment = wdListLevelAlignLeft .TextPosition = InchesToPoints(0.3) .TabPosition = InchesToPoints(0.3) .ResetOnHigher = 0 .StartAt = 1 With .Font .Bold = wdUndefined .Italic = wdUndefined .Strikethrough = wdUndefined .Subscript = wdUndefined .Superscript = wdUndefined .Shadow = wdUndefined .Outline = wdUndefined .Emboss = wdUndefined .Engrave = wdUndefined .AllCaps = wdUndefined .Hidden = wdUndefined .Underline = wdUndefined .Color = wdUndefined .Size = wdUndefined .Animation = wdUndefined .DoubleStrikeThrough = wdUndefined .Name = "" End With .LinkedStyle = "" End With ListGalleries(wdOutlineNumberGallery).ListTemplates(5).Name = "" Selection.Range.ListFormat.ApplyListTemplate ListTemplate:=ListGalleries( _ wdOutlineNumberGallery).ListTemplates(5), ContinuePreviousList:=True, _ ApplyTo:=wdListApplyToWholeList, DefaultListBehavior:= _ wdWord10ListBehavior
Now, I changed "Selection" to "oHeader1" but have an error... Maybe I just have the wrong type, Word.Paragraph.
Should be an easy one.




Reply With Quote