Click here to Skip to main content
15,887,283 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am writing code to set headings according to client requirement.

Desired//
Heading 1:
Font: (Default) Arial, 15 pt
Paragraph
  Spacing:
  Before: 8 pt
Outline Level: Level 1
Tabs:
Tab stops: 1.27 cm, List tab
Bullets and Numbering
List: Outline numbered
Level: 1
Numbering Style: 1,2,3,..
Start at:1
Alignment:Left
Aligned at:0 cm
Tab after: 1.27 cm
Indent at: 0 cm
Style
Style Linked, Quick Style
Based on: Normal

Achieved//
Heading 1:
Font: (Default) Arial, 15 pt
Paragraph
   Indentation:
   Left:0.25
   Hanging: 0.25
   Spacing:
   Before: 8 pt
   After: 0 pt
   Line and Page Breaks: Keep with next, Keep lines together
Outline Level: Level 1
Tabs:
Tab stops: 1.27 cm, Centered
Bullets and Numbering
List: Numbered
Level: 1
Numbering Style: 1,2,3,..
Start at:1
Alignment:Left
Aligned at:0.25"
Indent at:0.5"
Style
Style Linked, Quick Style, Priority:10
Based on: Normal
Following style:Normal

using <code>

 With oWord.ListGalleries(word.WdListGalleryType.wdOutlineNumberGallery).ListTemplates(1).ListLevels(1)
            .Alignment = word.WdListLevelAlignment.wdListLevelAlignLeft
            .StartAt = 1
            .NumberStyle = word.WdListNumberStyle.wdListNumberStyleArabic1

        End With

        Dim oTemplate1 As word.ListTemplate = oWord.ListGalleries.Item(word.WdListGalleryType.wdNumberGallery).ListTemplates.Item(1)



        With oDoc.Styles(word.WdBuiltinStyle.wdStyleHeading1)
            .Font.Bold = False

            .Font.Size = 15
            .Font.Name = "Arial"
            .Font.ColorIndex = word.WdColorIndex.wdAuto
            '.NameLocal = "Heading1"
            .ParagraphFormat.SpaceBefore = 6

            .ParagraphFormat.LeftIndent = False
            .ParagraphFormat.RightIndent = False

            .ParagraphFormat.OutlineLevel = word.WdOutlineLevel.wdOutlineLevel1
            .ParagraphFormat.Alignment = word.WdParagraphAlignment.wdAlignParagraphJustify

            With .ParagraphFormat.TabStops
                .Add(Position:=oWord.CentimetersToPoints(1.27), Alignment:=word.WdAlignmentTabAlignment.wdLeft)
            End With
            .ParagraphFormat.KeepWithNext = True
            .NextParagraphStyle = word.WdBuiltinStyle.wdStyleHeading1
            .QuickStyle = True
            .LinkToListTemplate(oTemplate1)


        End With

</code>

Now the difference

fol are added not required (how to turn them off or null)

1- Paragraph, Indentation: Left:0.25, Hanging: 0.25

2- Line and Page Breaks: Keep with next, Keep lines together

3- Tab stops: 1.27 cm, Centered (instead of List tab)

4- Bullets and Numbering List: Numbered (instead of Outline numbered)

5- Aligned at:0.25" (it should be zero i am not setting it anywhere)

6- Indent at:0.5" (it should be zero how to)

Please advice how to solve mentioned issues.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900