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

'' Demo of all built-in character styles
Public Class BuiltInCharStyles
    Public Function CreateDocx() As GcWordDocument
        Dim doc = New GcWordDocument()
        Dim sec = doc.Body.Sections.First
        Dim pars = sec.GetRange().Paragraphs

        pars.Add("Demo of All Built-in Character Styles", doc.Styles(BuiltInStyleId.Title))

        For Each id In [Enum].GetValues(GetType(BuiltInStyleId))
            If id = BuiltInStyleId.User Then
                Continue For
            End If
            Dim style = doc.Styles(id)
            If style.Type <> StyleType.Character Then
                Continue For
            End If

            pars.Add().GetRange().Runs.Add($"Text formatted using built-in character style '{style.Name}'.", style)
        Next

        '' Done
        Return doc
    End Function
End Class