WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WindowsLinuxPHPWEBDEV - Browser code
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Stored procedures
The docFragment type is used to define the characteristics of a fragment found in a "docx" document. The characteristics of this fragment can be defined and changed using different WLanguage properties.
A fragment is defined by its start and end positions. Therefore, it can:
  • extend on several paragraphs,
  • start in the middle of any ordinary word,
  • end in the middle of any ordinary word.
Remark: For more details on the declaration of this type of variable and the use of WLanguage properties, see Declaring a variable.
// Change the selection color
// Get the current selection
MySelection is docFragment(WP_MyDocument, WP_MyDocument.Cursor, ...
// Change the color
MySelection.Formatting.TextColor = PastelRed
// Load the document
MyDoc is Document = "c:\temp\doc.docx"
// Adds text at the end of document
FragmentEnd is docFragment(MyDoc, -1 , 0)
FragmentEnd.Text += "End of document"

Declaring a document fragment that is not described Hide the details

MyVariable is docFragment
In this case, the document fragment is not described. The variable will have to be assigned with an existing fragment or with the result of one of the functions for handling documents (DocSeek for example).

Declaring and describing a fragment Hide the details

MyVariable is docFragment([<Document> [, <Start of fragment> [, <Length>]]])
<Document>: Optional Document variable or character string
Document from which a fragment will be extracted. This document corresponds to:
<Start of fragment>: Optional integer
Start position of the document fragment to use. This position is given in number of characters:
  • from the start of document (positive number).
  • from the end of document (negative number).
<Length>: Optional integer
Length of fragment to use, expressed in number of characters.
Remark: a negative number allows you to take a number of characters starting from the end: '-1' = the end, '-2' = 1 character before the end, etc.

Properties specific to the description of docFragment variables

The following properties can be used to handle a docFragment variable:
Property nameType usedEffect
ElementArray of docElementElements making up the document fragment used. The fragment elements can be browsed via the FOR EACH statement.
RangeIntegerNumber of characters in the fragment. Corresponds to the end position minus the start position.
The extent can correspond to a positive, negative or zero value.
  • If the fragment contains a table or a section of a table, all characters in it are counted..
  • If the fragment contains an image or a text area, each one corresponds to 1 character.
SubDocumentIdentifierIntegerIdentifier corresponding to the subdocument associated with the fragment. This property is intended for an advanced use.
LanguageSpellingCharacter stringLanguage of fragment. The notation used corresponds to the 639-1 standard. For example "FR-fr".
In read mode, this property returns a valid information only if the fragment corresponds to a single language.
Remark: To perform the spell check corresponding to the fragment language, the dictionary of this language must be loaded by DictionaryLoad.
FormattingdocFormatting variableFormatting information for all the elements making up the document fragment used.
PageLayoutLayout of current fragment.
PageLayout.BackgroundColorIntegerBackground color of fragment. This color can correspond to:
PageLayout.BackgroundPatternBackground variableCharacteristics of fragment background.
WordArray of docFragmentWords making up the document fragment used. The fragment words can be browsed via the FOR EACH statement.
ParagraphArray of docParagraphParagraphs affected by the fragment (if a fragment includes several paragraphs). The paragraphs can be browsed via the FOR EACH statement.
StartPositionIntegerStart position of fragment. This position is relative to the entire document.
EndPositionIntegerEnd position of fragment. This position is relative to the entire document.
StyleIDCharacter stringIdentifier of style applied to the fragment. This identifier must exist among the styles linked to the document.
Remark: changing the paragraph or fragment style automatically applies the linked paragraph style and character style if they exist.
TextCharacter stringRough text corresponding to the content of fragment used.
TypeSubDocumentInteger constantSection of document to which the fragment belongs. The possible values are:
  • typeSubDocCanvas: Image container
  • typeSubDocBody: Document body.
  • typeSubDocHeaderOddPage: Header of odd page.
  • typeSubDocHeaderEvenPage: Header of even page.
  • typeSubDocHeaderFirstPage: Header of first page.
  • typeSubDocFooterOddPage: Footer of odd page.
  • typeSubDocFooterEvenPage: Footer of even page.
  • typeSubDocFooterFirstPage: Footer of first page.
  • typeSubDocTextArea: Text area.
This property is read-only.

WLanguage functions that use docFragment variables

docFragment variables are handled by several WLanguage functions:
  • WLanguage functions that use standard syntax:
    • at the end of a Word Processing document: an element, a document, a paragraph, a text, an image or a fragment.
    • at the end of a fragment: an element, a text or an image.
    DocInsertInserts an object into a Word Processing document or replaces the content of the current fragment. The objects that can be used are:
    • an element,
    • a document,
    • a paragraph,
    • a text,
    • an image,
    • a fragment.
    DocInsertTableInserts a table into a Word Processing document.
    DocFindFinds a character string:
    • in an entire Word Processing document.
    • in a fragment.
    DocSelectSelects a fragment in a Word Processing control.
  • WLanguage functions that use prefix syntax:
    <docFragment variable>.AddAdds an element, text or image at the end of a docFragment variable.
    <docFragment variable>.InsertTableReplaces the specified fragment with a table.
    <docFragment variable>.InsertReplaces the content of the current fragment. The objects that can be used are:
    • an element,
    • a document,
    • a paragraph,
    • a text,
    • an image,
    • a fragment.
Minimum version required
  • Version 22
This page is also available for…
Click [Add] to post a comment