Home Forums General XMetaL Discussion MoveToElement() Help Reply To: MoveToElement() Help

Derek Read

Reply to: MoveToElement() Help

You are correct. The call to SelectContainerContents() will stop MoveToElement from moving further.
Including it in my example demonstrates that:

[code]//XMetaL Script Language JScript:
var rng = ActiveDocument.Range;
rng.MoveToDocumentStart();
while(rng.MoveToElement()) {
rng.SelectContainerContents();
Application.Alert(rng.ContainerName);
}[/code]

So, I'd say you need to modify your code so that the selection is turned back into an insertion point. Here's the exact same example but doing what I  I think you need:

[code]//XMetaL Script Language JScript:
var rng = ActiveDocument.Range;
rng.MoveToDocumentStart();
while(rng.MoveToElement()) {
rng.SelectContainerContents();
Application.Alert(rng.ContainerName); //most of your code that modifies stuff would probably go here
rng.Collapse(1);
}[/code]

Reply

Products
Downloads
Support