General XMetaL Discussion
XMetaL Community Forum › General XMetaL Discussion › strElementName
-
C4 April 26, 2017 at 1:10 am
strElementName
April 26, 2017 at 1:10 amParticipants 2Replies 3Last Activity 5 years, 9 months agoHi,
We are using XMetal Author Essential 11.
I'm trying to write a macro to find an element using:
// XMetaL Script Language JSCRIPT:
var rng=ActiveDocument.Range;
rng.MoveToElement(“P”,false);
// make the range visible
rng.Select();Is there any way to move to the end of the element rather than the beginning of the element?
Thanks.
tonys April 26, 2017 at 9:34 pm
Reply to: strElementName
April 26, 2017 at 9:34 pmTo move the cursor before the end tag:
rng.MoveToElement(“P”);
rng.SelectContainerContents();
rng.Collapse(0);To move after the end tag:
rng.MoveToElement(“P”);
rng.SelectAfterContainer();C4 April 26, 2017 at 11:55 pm
Reply to: strElementName
April 26, 2017 at 11:55 pmThanks
I tried both of those and it took me to the beginning of the element.
I've changed my code to this and it seems to work.
var rng=ActiveDocument.Range;
rng.MoveToElement(“P”,true);
rng.Select();
Selection.SelectAfterNode(Selection.ContainerNode); -
AuthorPosts
- You must be logged in to reply to this topic.