Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Does anyone know what is the correct code for getting and setting variable value in JScript?
I use the following code which is not working (obviously):
function getVariable(varName) {
var doc = ActiveDocument;
var vget = doc.Variables(varName);
getVariable = vget.Value;
}
function setVariable(varName, varValue) {
var doc = ActiveDocument;
var vset = doc.Variables(varValue);
vset.SetVariable(varName, varValue);
doc = null;
}
Thank you very much in advance.
Try something like this:
function setVariable(varName, varValue) {
var doc = ActiveDocument;
var vset = doc.Variables(varName);
vset.SetContent varValue;
doc = null;
}
It fails to parse. Unless I change this vset.SetContent varValue;
to this vset.SetContent (varValue);
But that doesn't help as well...
Maybe this is helpful: JavaScript Function in WebView
- Marcus
Thanks Marcus. Unfortunately, not.
Some modifications and setVariable works, but how to make getVariable work?
function setVariable(varName, varValue) {
var doc = ActiveDocument;
var v = doc.Variables(varName)
v.SetContent(varValue, true);
}
Maybe:
function getVariable(varName) {
var doc = ActiveDocument;
var vget = doc.Variables(varName);
getVariable = vget.GetContent.String;
}
- Marcus
No luck
Maybe this more helpful: Read QV-Variables via JavaScript
- Marcus