I want to add variables to a template.
When I add the variables & run the code, the next time I open the template it seems the variables have been saved to the template instead of needing to be added with each document instance of the template?
How do I add the variable to the template such that it will not keep trying to readd that variable each time the template is opened? The only thing I've seen thus far is a for loop nested in an if loop that tests each variable to see if its name matches the one in question, but this seems inefficient - especially when I am using many variables.
I am working under the template, but I am working in the code part of the UserForm. Should I be writing a macro within the module instead to add the variables, then running it once?
i am not quite sure i understand but if the variables values are saved, which is strange just set them to "" or appropriate nil value on document open or document new as the case might be
or possibly when you create the variables, create a boolean to tell you that all the variables are created
How are docvariables (the ones that integrate with field code under Insert/Field/DocVariable) within the document itself typically created (for templates)? I know the code, but do I put the code to create them in the userform that will assign their values, or in a macro within the modules, or in the initialization code, or where?
Putting a boolean in that tells me it exists would be great if they had an exists property for the docvariables. As it is, I'm not sure how that would work, except maybe through some error code?