Documents for Word .NET Edition
Features / Glossary Document
In This Topic
    Glossary Document
    In This Topic

    A glossary document is a supplementary storage which stores the content, such as AutoText/Buildingblock entries that you do not want to appear in the document, but want to keep it as the part of document for future insertion, if needed. GcWord provides the capability of maintaining a GlossaryDocument for a Word document to store the BuildingBlocks content. It is represented using the GlossaryDocument class.

    GlossaryDocument class maintains the collection of building blocks using the BuildingBlockCollection class. The BuildingBlockCollection class provides Add and Remove method to add and remove the blocks from the glossary document respectively.

    Building blocks is an essential feature of word which allows you to insert blocks of information in the document. These blocks of information can be reusable chunks of content or pre-designed and pre-formatted blocks of text and formatting. GcWord allows you to create, modify and delete building blocks using the BuildingBlock class.

    Create Building Block in Glossary Document

    To create and add building blocks in a glossary document:

    1. Create an instance of the GcWordDocument class to create a document. The GlossaryDocument property of this class returns the Glossary Document specific to the Word document.
    2. Add the building block to the Glossary document using the Add method of BuildingBlockCollection.
      C#
      Copy Code
      GcWordDocument doc = new GcWordDocument();
      
      //Adds a building block that contains text
      BuildingBlock bb1 = doc.GlossaryDocument.BuildingBlocks.Add("Mission_Statement", "CompanyInfo", BuildingBlockGallery.AutoText, BuildingBlockInsertOptions.Content, BuildingBlockType.None);
      Style paraStyle = bb1.Body.Document.Styles.Add("paraStyle", StyleType.Paragraph);
      paraStyle.Font.Bold = true;          
      bb1.Body.Paragraphs.Add("To serve our customers by helping them to achieve their goals", paraStyle);
      
      //Save the document (Note:Building blocks can be saved in dotx and docx, but in the docx format, MS Word UI won't show them)
      doc.Save("CustomBuildingBlocks.dotx", DocumentType.Template);
    Back to Top

    Remove Building Block from Glossary Document 

    To remove building block from glossary document:

    1. Load the document using Load method of GcWordDocument class.
    2. Invoke Remove method of the BuildingBlockCollection class to remove the building block from glossary document.
      C#
      Copy Code
      GcWordDocument doc = new GcWordDocument();
      doc.Load("CustomBuildingBlocks.dotx");
      doc.GlossaryDocument.BuildingBlocks.Remove(doc.GlossaryDocument.BuildingBlocks.First);

    Back to Top