GlossaryDoc.vb
  1. ''
  2. '' This code is part of Document Solutions for Word demos.
  3. '' Copyright (c) MESCIUS inc. All rights reserved.
  4. ''
  5. Imports System.IO
  6. Imports System.Drawing
  7. Imports System.Collections.Generic
  8. Imports System.Linq
  9. Imports System.Xml
  10. Imports GrapeCity.Documents.Word
  11.  
  12. '' This sample demonstrates how to add building blocks to a document's glossary.
  13. Public Class GlossaryDoc
  14. Function CreateDocx() As GcWordDocument
  15. Dim doc = New GcWordDocument()
  16.  
  17. doc.Body.Paragraphs.Add(
  18. "This sample demonstrates adding building blocks (custom headers and footers in this case) " +
  19. "to the document's glossary. They do not show in the generated document. To use the building blocks, " +
  20. "open the document in MS Word and explore the document's glossary.")
  21.  
  22. '' Add header And footer building blocks to the document's glossary:
  23. AddHeaderBuildingBlockToGlossary(doc)
  24. AddFooterBuildingBlockToGlossary(doc)
  25.  
  26. '' Now the document has two building blocks in the glossary.
  27. '' Note that when the document Is loaded into MS Word, they will Not be visible.
  28. '' To use them, open the document in MS Word And explore the document glossary.
  29. Return doc
  30. End Function
  31.  
  32. '' Add header building block
  33. Private Sub AddHeaderBuildingBlockToGlossary(ByRef doc As GcWordDocument)
  34. Dim glossary = doc.GlossaryDocument
  35. Dim buildingBlocks = glossary.BuildingBlocks
  36. Dim buildingBlock = buildingBlocks.Add("New cool header", "2019 collection", BuildingBlockGallery.CustomHeaders)
  37. Dim bbBody = buildingBlock.Body
  38. ''here we can modify body as we want
  39. Dim p = bbBody.Paragraphs.Add("New cool building block neader")
  40. p.Style.Font.Color.RGB = Color.Blue
  41. End Sub
  42.  
  43. '' Add footer building block
  44. Private Sub AddFooterBuildingBlockToGlossary(ByRef doc As GcWordDocument)
  45. Dim glossary = doc.GlossaryDocument
  46. Dim buildingBlocks = glossary.BuildingBlocks
  47. Dim buildingBlock = buildingBlocks.Add("New cool footer", "2019 collection", BuildingBlockGallery.CustomFooter)
  48. Dim bbBody = buildingBlock.Body
  49. '' Here we can modify the body as we want:
  50. Dim p = bbBody.Paragraphs.Add("New cool building block footer")
  51. p.Style.Font.Color.RGB = Color.Pink
  52. End Sub
  53. End Class
  54.