GlossaryDoc.vb
- ''
- '' This code is part of Document Solutions for Word demos.
- '' Copyright (c) MESCIUS inc. All rights reserved.
- ''
- Imports System.IO
- Imports System.Drawing
- Imports System.Collections.Generic
- Imports System.Linq
- Imports System.Xml
- Imports GrapeCity.Documents.Word
-
- '' This sample demonstrates how to add building blocks to a document's glossary.
- Public Class GlossaryDoc
- Function CreateDocx() As GcWordDocument
- Dim doc = New GcWordDocument()
-
- doc.Body.Paragraphs.Add(
- "This sample demonstrates adding building blocks (custom headers and footers in this case) " +
- "to the document's glossary. They do not show in the generated document. To use the building blocks, " +
- "open the document in MS Word and explore the document's glossary.")
-
- '' Add header And footer building blocks to the document's glossary:
- AddHeaderBuildingBlockToGlossary(doc)
- AddFooterBuildingBlockToGlossary(doc)
-
- '' Now the document has two building blocks in the glossary.
- '' Note that when the document Is loaded into MS Word, they will Not be visible.
- '' To use them, open the document in MS Word And explore the document glossary.
- Return doc
- End Function
-
- '' Add header building block
- Private Sub AddHeaderBuildingBlockToGlossary(ByRef doc As GcWordDocument)
- Dim glossary = doc.GlossaryDocument
- Dim buildingBlocks = glossary.BuildingBlocks
- Dim buildingBlock = buildingBlocks.Add("New cool header", "2019 collection", BuildingBlockGallery.CustomHeaders)
- Dim bbBody = buildingBlock.Body
- ''here we can modify body as we want
- Dim p = bbBody.Paragraphs.Add("New cool building block neader")
- p.Style.Font.Color.RGB = Color.Blue
- End Sub
-
- '' Add footer building block
- Private Sub AddFooterBuildingBlockToGlossary(ByRef doc As GcWordDocument)
- Dim glossary = doc.GlossaryDocument
- Dim buildingBlocks = glossary.BuildingBlocks
- Dim buildingBlock = buildingBlocks.Add("New cool footer", "2019 collection", BuildingBlockGallery.CustomFooter)
- Dim bbBody = buildingBlock.Body
- '' Here we can modify the body as we want:
- Dim p = bbBody.Paragraphs.Add("New cool building block footer")
- p.Style.Font.Color.RGB = Color.Pink
- End Sub
- End Class
-