PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • 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
Trace(ADocStyle..StyleID)
END

// 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)
END
END
// 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, ...
MyDocControl..SelectionLength)
// Applies the Title1 style to the selection
f.StyleID = StyleTitle1ForSelection..Identifier
END
Minimum version required
  • Version 22
This page is also available for…
Comments
Click [Add] to post a comment