Help / WLanguage / WLanguage functions / Controls, pages and windows / Word Processing functions / Types of variables
  • Importing the styles of document
Document (Example)
Importing the styles of document
This example is used to list the styles of a document to add the requested style into another document.
// List the styles of a document
MyDocControl is Control
// Retrieve an associated document
MyDoc is Document = MyDocControl
// List all the styles used by the document
FOR EACH ADocStyle OF MyDoc.Style
// Add the "Title1" style into a document and apply it to the selection
// The definition of "Title1" style comes from another document
MyDocControl is Control = {"MyWPControl", indControl}
// Retrieve an associated document
MyDoc is Document = MyDocControl
// If the "Title1" style does not exist,
// add it from a document containing preset styles
IF MyDoc.Style["Title1"] = Null THEN
// Opens a document containing the styles
MyDocContainingTheStyles is Document = "c:\MyDocWithMyStyles.docx"
// Retrieves the Title 1 style
StyleTitle1 is docStyle <- MyDocContainingTheStyles.Style["Title1"]
IF StyleTitle1 <> Null THEN
// Adds the style into the document
Add(MyDoc.Style, StyleTitle1)
// Apply the style to the selection
StyleTitle1ForSelection is docStyle <- MyDoc.Style["Title1"]
IF StyleTitle1ForSelection <> Null THEN
// Create the fragment (from the selection)
f is docFragment(MyDocControl.Value, MyDocControl.Cursor, ...
// Applies the Title1 style to the selection
f.StyleID = StyleTitle1ForSelection.Identifier
Minimum version required
  • Version 22
This page is also available for…
Click [Add] to post a comment

Last update: 05/26/2022

Send a report | Local help