Forum Discussion

JDR2500's avatar
JDR2500
Frequent Contributor
2 months ago

Setting default project variable values via scripts?

I have a script that creates a project variable if it doesn't already exist in the project.  This saves me the trouble of opening every project and manually creating the variable.  That works great.  This is the VBScript I use:

Set Variables = Project.Variables
If Not Variables.VariableExists("MyVariable") Then
      Variables.AddVariable "MyVariable", "Integer"
End If


When the script creates the variable, in this case type integer, via AddVariable the value is set to "0".  That's not what I want.  I want the value set to "1".  However, I can't find anyway to set default values via scripts, only the local value.  

Has anyone found a solution to this?  My impression is it can't be done.  I couldn't find any scripting method for setting the default values.

I can work around this by using the local value.  I just found it odd that you can't set the default.  It appears you can't set the description at creation time either, again an odd omission.

2 Replies