ModifyFormat.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
  6. Imports System.IO
  7. Imports System.Collections.Generic
  8. Imports System.Linq
  9. Imports System.Drawing
  10. Imports GrapeCity.Documents.Word
  11.  
  12. '' This sample loads an existing DOCX And modifies
  13. '' some of the built-in styles.
  14. Public Class ModifyFormat
  15. Public Function CreateDocx() As GcWordDocument
  16. Dim doc = New GcWordDocument()
  17.  
  18. '' Load an existing DOCX file
  19. Dim path = System.IO.Path.Combine("Resources", "WordDocs", "JsFrameworkExcerpt.docx")
  20. doc.Load(path)
  21.  
  22. '' Modify the title And sub-title styles
  23. doc.Styles(BuiltInStyleId.Title).ParagraphFormat.Shading.BackgroundPatternColor.RGB = Color.PaleGoldenrod
  24. doc.Styles(BuiltInStyleId.Title).Font.Color.RGB = Color.OrangeRed
  25.  
  26. doc.Styles(BuiltInStyleId.Subtitle).Font.Color.RGB = Color.MediumVioletRed
  27. doc.Styles(BuiltInStyleId.Subtitle).Font.Italic = True
  28.  
  29. '' Modify the top 4 heading styles
  30. Dim headings As New List(Of Style) From
  31. {
  32. doc.Styles(BuiltInStyleId.Heading1),
  33. doc.Styles(BuiltInStyleId.Heading2),
  34. doc.Styles(BuiltInStyleId.Heading3),
  35. doc.Styles(BuiltInStyleId.Heading4)
  36. }
  37. For Each heading In headings
  38. heading.Font.Color.RGB = Color.Blue
  39. heading.Font.Bold = True
  40. heading.Font.Italic = True
  41. Next
  42.  
  43. '' Done
  44. Return doc
  45. End Function
  46. End Class
  47.