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

edporterIII

Reply to: MoveToElement() Help

The issue appears to be that when I select the container contents, the while loop won't go any further into that particular container. For example, if there's an entry or emph tag within a para, the code below will not pick them up. If you remove the SelectContainerContents method call, it will.

[code]
var rng_Document = ActiveDocument.Range;
rng_Document.MoveToDocumentStart();
var space = ” “;
var tag = “”;
while (rng_Document.MoveToElement()) {
tag = tag + rng_Document.ContainerName + “n”;
switch (rng_Document.ContainerName) {
case “emph”:
case “entry”:
case “para”:
rng_Document.SelectContainerContents();

break;
}
[/code]

My goal is to find a space immediately following an opening tag or preceding a closing tag, and wrap a comment around it. What would be the best way to modify the active document and not disrupt this while loop?

Reply

Products
Downloads
Support