Home Forums DITA and XMetaL Discussion Using the MoveToElement method to set attribute values Reply To: Using the MoveToElement method to set attribute values

Derek Read

Reply to: Using the MoveToElement method to set attribute values

Something like this?

[code]var rng = ActiveDocument.Range;
rng.MoveToDocumentStart();
while (rng.MoveToElement(“Section”)) {
rng.ContainerAttribute(“numbering”) = “on”;
}[/code]

The verbose version (with JScript comments):
[code]//create a Range object named rng
//this is created at the user's current selection in the document
var rng = ActiveDocument.Range;

//move the rng to the start of the document
rng.MoveToDocumentStart();

//repeatedly move to the next element named “Section” until that fails
//and each time that is successful do whatever is inside the loop's {}
while (rng.MoveToElement(“Section”)) {
//set the value for the “numbering” attribute inside the current rng's container to “on”
rng.ContainerAttribute(“numbering”) = “on”;
}[/code]

Reply

Products
Downloads
Support