ModifyFormat.vb
''
'' This code is part of GrapeCity Documents for Word samples.
'' Copyright (c) GrapeCity, Inc. All rights reserved.
''
Imports System
Imports System.IO
Imports System.Collections.Generic
Imports System.Linq
Imports System.Drawing
Imports GrapeCity.Documents.Word

'' This sample loads an existing DOCX And modifies
'' some of the built-in styles.
Public Class ModifyFormat
    Public Function CreateDocx() As GcWordDocument
        Dim doc = New GcWordDocument()

        '' Load an existing DOCX file
        Dim path = System.IO.Path.Combine("Resources", "WordDocs", "JsFrameworkExcerpt.docx")
        doc.Load(path)

        '' Modify the title And sub-title styles
        doc.Styles(BuiltInStyleId.Title).ParagraphFormat.Shading.BackgroundPatternColor.RGB = Color.PaleGoldenrod
        doc.Styles(BuiltInStyleId.Title).Font.Color.RGB = Color.OrangeRed

        doc.Styles(BuiltInStyleId.Subtitle).Font.Color.RGB = Color.MediumVioletRed
        doc.Styles(BuiltInStyleId.Subtitle).Font.Italic = True

        '' Modify the top 4 heading styles
        Dim headings As New List(Of Style) From
        {
            doc.Styles(BuiltInStyleId.Heading1),
            doc.Styles(BuiltInStyleId.Heading2),
            doc.Styles(BuiltInStyleId.Heading3),
            doc.Styles(BuiltInStyleId.Heading4)
        }
        For Each heading In headings
            heading.Font.Color.RGB = Color.Blue
            heading.Font.Bold = True
            heading.Font.Italic = True
        Next

        '' Done
        Return doc
    End Function
End Class