none
Word Style Headings Settings vb.net RRS feed

  • Question

  • 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.

    Monday, March 30, 2015 4:13 AM

Answers

  • Hi Rakesh,

    Thanks for posting in MSDN forum.

    According to the desciption, you were developing with Word appliaition.

    What we are interested in is what objects, methods, and properties we need to use. The best way to learn how to navigate the object models of Word, Excel, and Powerpoint, based on what you want to do as a user, is to use the Macro Recorder. For example, that we can use code below to set the left indent of paragraph to 0.25:

    Selection.ParagraphFormat.CharacterUnitLeftIndent = 0.25

    And here is the link for your refer to Word object model:
    Object model reference (Word 2013 developer reference)

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, March 31, 2015 2:48 AM
    Moderator