Home Forums General XMetaL Discussion Call VBScript function from JScript? Reply To: Call VBScript function from JScript?

Derek Read

Reply to: Call VBScript function from JScript?

Because of the way Windows script engines work you cannot mix things like this.
I can think of two solutions I can think of.

1) Rewrite the function that is being called in JScript or rewrite the calling code in VBscript.

2) Leave things as you have them and use a DocumentProperties object to temporarily store your string then at the start of the called macro read the value in.

Here are examples directly from the Programmer's Guide:

Setting a value using the Add method:
[code]var curDoc, curDocProps;
curDoc=Application.ActiveDocument;
curDocProps=curDoc.CustomDocumentProperties;
curDocProps.Add(“PreviewTempFile”,”foo.xml”);[/code]

Reading the value using the Item method (I've changed the last line to be an Alert rather than SaveAs):
[code]var curDoc, curDocProps, ptf;
curDoc=Application.ActiveDocument;
curDocProps=curDoc.CustomDocumentProperties;
ptf = curDocProps.item(“PreviewTempFile”);
Application.Alert(ptf.Value);[/code]

Which of these two options is more work I cannot say as you have simplified your example. If it was truly as you have written, or even if it was 10 or 20 lines, I'd probably take a few minutes to rewrite one of them just to make things easier to debug.

In general I would recommend standardizing on one scripting language for everything and then maybe, if there was something only a specific language can do, make that one exception (however, in my experience there always seems to be a way).

Reply

Products
Downloads
Support