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

'' This sample demonstrates how to use built-in styles
'' to format a document.
Public Class SomeCommonStyles
    Public Function CreateDocx() As GcWordDocument
        Dim doc = New GcWordDocument()
        Dim sec = doc.Body.Sections.First
        Dim pars = sec.GetRange().Paragraphs

        '' Title:
        pars.Add("Some Common Built-in Styles (Title)", doc.Styles(BuiltInStyleId.Title))

        '' Title:
        pars.Add("Demonstration of some of the built-in styles. (Subtitle)", doc.Styles(BuiltInStyleId.Subtitle))

        '' Headings 1-4:
        Dim heading1 = pars.Add("Heading 1", doc.Styles(BuiltInStyleId.Heading1))
        Dim heading2 = pars.Add("Heading 2", doc.Styles(BuiltInStyleId.Heading2))
        Dim heading3 = pars.Add("Heading 3", doc.Styles(BuiltInStyleId.Heading3))
        Dim heading4 = pars.Add("Heading 4", doc.Styles(BuiltInStyleId.Heading4))

        '' Normal Text:
        pars.Add("This and the following 'lorem impum' paragraph use the 'Normal' style.")
        pars.Add(SmallPara())

        '' Quote:
        pars.Add("The next paragraph uses the 'Quote' style:")
        Dim p = pars.Add(SmallPara(), doc.Styles(BuiltInStyleId.Quote))
        p.Style.ParagraphFormat.KeepTogether = True

        '' Intense Quote:
        pars.Add("The next paragraph uses the 'Intense Quote' style:")
        p = pars.Add(SmallPara(), doc.Styles(BuiltInStyleId.IntenseQuote))
        p.Style.ParagraphFormat.KeepTogether = True

        '' Intense Quote:
        pars.Add("The next paragraph uses the 'List Paragraph' style:")
        p = pars.Add(SmallPara(), doc.Styles(BuiltInStyleId.ListParagraph))
        p.Style.ParagraphFormat.KeepTogether = True

        '' Character styles:
        p = pars.Add("In this paragraph we demonstrate some of the built-in character styles. ")
        Dim runs = p.GetRange().Runs
        runs.Add("This run uses the 'Strong' style. ", doc.Styles(BuiltInStyleId.Strong))
        runs.Add("A run of normal text. ")
        runs.Add("This run uses 'Emphasis' style. ", doc.Styles(BuiltInStyleId.Emphasis))
        runs.Add("A run of normal text. ")
        runs.Add("This run uses 'Intense Emphasis' style. ", doc.Styles(BuiltInStyleId.IntenseEmphasis))
        runs.Add("A run of normal text. ")
        runs.Add("This run uses 'Subtle Emphasis' style. ", doc.Styles(BuiltInStyleId.SubtleEmphasis))

        pars.Add("The End.")

        '' Done:
        Return doc
    End Function

    Private Function SmallPara() As String
        Return Util.LoremIpsumPar(2, 3, 4, 5)
    End Function
End Class