I want to create a template file in which I want to create my own styles programatically(in VBA)
I have following code

Sub Style()

Dim myStyle As Style

Set myStyle = ActiveDocument.Styles.Add(Name:="Abbreviations", _
    Type:=wdStyleTypeParagraph)

With myStyle.Font
    .Name = "Calibri"
    .Size = 12
    .Color = wdColorBlue

End With

Selection.Range.Style = "Abbreviations"

but i cant set properties like style Automatically update, based on and space after... before
please help me
thanks in advance

Set styleNew = ActiveDocument.Styles.Add(Name:="Stle 1", _
    Type:=wdStyleTypeParagraph)


With styleNew
    .Font.Name = "Calibiri"
    .Font.Size = 12
    .Font.Color = wdColorBlue
    .ParagraphFormat.LineSpacingRule = wdLineSpaceSingle
    .ParagraphFormat.LeftIndent = InchesToPoints(0.5)
    .ParagraphFormat.RightIndent = InchesToPoints(0.5)
    .ParagraphFormat.SpaceAfter = 12
    .ParagraphFormat.SpaceBefore = 12
    .AutomaticallyUpdate = True
    '.BaseStyle = docNew.Styles(wdStyleNormal)
End With

Selection.Range.style = "Style 1"

This helped me a lot

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.