GetStyleSource.vb
- ''
- '' This code is part of Document Solutions for Word demos.
- '' Copyright (c) MESCIUS inc. All rights reserved.
- ''
- Imports System.IO
- Imports GrapeCity.Documents.Word
-
- '' The actual formatting of a specific content object in an MS Word document
- '' Is determined by a combination of several factors, such as direct formatting
- '' that may be applied to the object, the style associated with the object,
- '' as well as direct formatting And styles of the containing objects.
- ''
- '' This sample demonstrates the use of the GcWordDocument.GetPropertyValueSource()
- '' method that allows to find the object that provides the actual current value
- '' of a style property (in this sample, the size of a font).
- ''
- '' This sample uses the document from the SampleParagraphs sample.
- Public Class GetStyleSource
- Function CreateDocx() As GcWordDocument
- Dim doc = New GcWordDocument()
- doc.Load(Path.Combine("Resources", "WordDocs", "SampleParagraphs.docx"))
-
- '' Find the object that provides formatting for the first text run in this document
- Dim source = GcWordDocument.GetPropertyValueSource(Function() doc.Body.Runs.First.Font.Size)
-
- '' Add the info that we found to the document
- doc.Body.Paragraphs.Add($">>> The object that determines the font size of the first text run in this document Is '{source}'.")
- '' If the property source Is a style, add its name
- If source IsNot Nothing AndAlso source.GetType() Is GetType(Style) Then
- doc.Body.Paragraphs.Add($">>> The object Is the style '{CType(source, Style).WordName}'.")
- End If
-
- Return doc
- End Function
- End Class
-