Answered
Custom Text Variable
I want to create a text variable using User Name. I am not verry good at scripting, so, hopefully someone can help me.
Thanks
I want to create a text variable using User Name. I am not verry good at scripting, so, hopefully someone can help me.
Thanks
Nothing happens when I createa text box and run the script
The script I posted just creates the user name text variable. Try the script below to add the text variable to the selected text box you created.
function isMacOS() {
return ($.os.toLowerCase().indexOf('mac') >= 0);
}
function getUserName() {
return (isMacOS()) ? $.getenv("USER") : $.getenv("USERNAME");
}
try{app.activeDocument.textVariables.add({name: "User Name", variableType:VariableTypes.CUSTOM_TEXT_TYPE,});
app.activeDocument.textVariables.item("User Name").variableOptions.contents = getUserName();
} catch (e) {
}
var mySelection = app.selection[0];
var myUserNametextVariable = app.activeDocument.textVariables.item("User Name");
mySelection.texts[0].textVariableInstances.add({associatedTextVariable:myUserNametextVariable});
Regards,
Mike
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.