Altova StyleVision 2025 Enterprise Edition

AuthenticRange.SetElementAttributeValue

Home Prev Top Next

Method: SetElementAttributeValue (strElementName as String, strAttributeName as String, strAttributeValue as String)

 

Description

Set the value of the attribute specified in strAttributeName for the element identified with strElementName. If the attribute is supported but has no value assigned, the empty string is returned. To find out the names of attributes supported by an element, use GetElementAttributeNames, or HasElementAttribute.

 

Errors

2001

The authentic range object or its related view object is no longer valid.

2005

Invalid element name was specified.

Invalid attribute name was specified.

Invalid attribute value was specified.

 

Examples

' --------------------------------------------

' Scripting environment - VBScript

' Get and set element attributes

' --------------------------------------------

Dim objRange

' we assume that the active document is open in authentic view mode

Set objRange = Application.ActiveDocument.AuthenticView.Selection

 

' first we find out all the elements below the beginning of the range

Dim arrElements

objRange.GetElementHierarchy arrElements

 

If IsArray(arrElements) Then

 If UBound(arrElements) >= 0 Then

         ' we use the top level element and find out its valid attributes

         Dim arrAttrs()

         objRange.GetElementAttributeNames arrElements(0), arrAttrs

 

         If UBound(arrAttrs) >= 0 Then

                 ' we retrieve the current value of the first valid attribute

                 Dim strAttrVal

                 strAttrVal = objRange.GetElementAttributeValue (arrElements(0), arrAttrs(0))

                 msgbox "current value of " & arrElements(0) & "//" & arrAttrs(0) & " is: " & strAttrVal

 

                 ' we change this value and read it again

                 strAttrVal = "Hello"

                 objRange.SetElementAttributeValue arrElements(0), arrAttrs(0), strAttrVal

                 strAttrVal = objRange.GetElementAttributeValue (arrElements(0), arrAttrs(0))

                 msgbox "new value of " & arrElements(0) & "//" & arrAttrs(0) & " is: " & strAttrVal

         End If

 End If

End If

 

 

© 2018-2024 Altova GmbH