Skip to main content
Version: Next

WP Get element by ID

WP Get element by ID ( wpDoc ; ID ) : Object

ParameterTypeDescription
wpDocObject4D Write Pro document
IDTextIdentifier of the element to retrieve
Function resultObject4D Write Pro element

Description

The WP Get element by ID command returns an object containing the element of wpDoc passed in the ID parameter.

In the wpDoc parameter, pass a 4D Write Pro document.

Pass the ID attribute of the element to retrieve in the ID parameter. The element can be within the document, such as an image, a paragraph, a table, row, etc., or the document itself. If no elements in the document have the specified ID, a null value is returned.

Note: The ID parameter value is case-sensitive.

Example 1

To get the picture with the ID "img1":

 var obImage : Object
 obImage:=WP Get element by ID(myDoc;"img1")

Example 2

You want to find a table element and modify it to have a large purple border:

 var $element : Object
 $element:=WP Get element by ID(myDoc;"Table1")
 WP SET ATTRIBUTES($element;wk border style;wk solid)
 WP SET ATTRIBUTES($element;wk border width;"4px")
 WP SET ATTRIBUTES($element;wk border color;"purple")

Example 3

You want to retrieve an element and modify its ID:

 $colTable:=WP Create table range([INFO]Sample)
 $elements:=WP Get elements($colTable)
 $elem:=WP Get element by ID([INFO]Sample;"Paris")
 If($elem#Null)
    $elem.ID:="Lyon"
 End if

See also

WP Get elements