ListBuiltInStyles.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.Drawing
  6. Imports System.IO
  7. Imports System.Linq
  8. Imports GrapeCity.Documents.Word
  9. Imports GrapeCity.Documents.Imaging
  10.  
  11. '' This sample lists all built-in styles available in DsWord.
  12. Public Class ListBuiltInStyles
  13. Public Function CreateDocx() As GcWordDocument
  14. Dim doc = New GcWordDocument()
  15. Dim pars = doc.Body.Paragraphs
  16.  
  17. pars.Add("List of All Built-in Styles", doc.Styles(BuiltInStyleId.Title))
  18.  
  19. '' List all built-in style names and types.
  20. '' Note that BuiltInStyleId.User is a special case that is not associated
  21. '' with any built-in style. This value is returned by the Style.BuiltInId
  22. '' property for user-defined styles, but cannot be used as an index
  23. '' on the Styles collection (an exception will occur):
  24. For Each id In [Enum].GetValues(GetType(BuiltInStyleId))
  25. If id <> BuiltInStyleId.User Then
  26. pars.Add($"Style name '{doc.Styles(id).Name}', type: '{doc.Styles(id).Type}'.")
  27. End If
  28. Next
  29.  
  30. '' Done:
  31. Return doc
  32. End Function
  33. End Class
  34.