Home Forums General XMetaL Discussion I wann to know whether xmetal support javascript for macro. Reply To: I wann to know whether xmetal support javascript for macro.

Derek Read

Reply to: I wann to know whether xmetal support javascript for macro.

You might try something like the following:

[code]//XMetaL Script Language JScript:
var rng = ActiveDocument.Range;
var elemName = “LI”;
if (rng.MoveToElement(elemName,false)) {
rng.SelectElement();
var prevElem = rng.Text;
Application.Alert(prevElem);
rng.FindInsertLocation(elemName);
rng.Select();
if (rng.CanPaste(prevElem)) {
rng.PasteString(prevElem);
}
else {
Application.Alert(“Unable to find a location to insert a new <" + elemName + ">.”);
}
}
else {
Application.Alert(“There is no previous <" + elemName + "> in this document.”);
}[/code]

This is just an example. There will be many other possible ways to write similar functionality. It also might not do exactly what you want, so you'll need to tweak it in that case.

You'll all want to build that into an MCR file for deployment with your DTD / XSD, or you could put it into an application level MCR file so that it is available to all schema, one that sits in the AuthorStartup folder. However, it seems like this is a schema-specific script (ie: not every document type is going to support

  • ). Deployment is discussed in XMetaL Developer in the Customization Guide.
  • Reply

    Products
    Downloads
    Support