Joe Busch said:
Good Day all,
Let me preface to say that I am not looking to have someone do something for
me, rather I am trying to determine if the following is possible and how
best to proceed.
I would like to create a document that creates letterhead for new staff. It
would ask them for their name, title, center and phone extension; then take
that information to generate a letterhead template.
Any ideas or suggestions are greatly appreciated.
I am using Word 2003.
You can do this with or without VBA...
In both cases, I would use Custom Document Properties (File > Properties >
Custom Tab). In know you could use Built-in ones for some of the values, like
NAME, but I find it easier to have everyting in one place... But you could
use a mix of built-in and custom properties if you want to.
Create one Custom Text property for each bit of info you need.
Use Default text as values, like "Full Name", "Company", "Department", etc.
In the text, where ever you want those values to appear, use DOCPROPERTY
fields.
Now, if you do not want to use VBA, you have to instruct users to open the
template itself (not a document based on the template) and change the default
values.
If using VBA, create a userform that will ask the user to provide those
values. The code would update the values for the properties. When you display
the userform, read the actual property values and insert them in the userform
so the user can see the current values (even if they are the default ones;
however, if you do detect default values, you could leave the textboxes on
the userform blank...).
Create a toolbar button that will call that userform so that the user can
update those values whenever necessary.
Make sure the code changes the values in the emaplte *AND* the current
document (Once a document is created from the template, its custom properties
are independant). To see this in action, create a document based on a
template that has your name as its "Author" value. Then, once the document is
opened, change the value in the document to some other text string. Try this
to see the difference:
MsgBox ActiveDocument.BuiltInDocumentProperties(wdPropertyAuthor).Value
MsgBox AttachedTemplate.BuiltInDocumentProperties(wdPropertyAuthor).Value
When a document is created from the template, the code should check if the
properties have their default values, if so, it means user has never updated
them, pop-up the userform so the user can do so; otherwise, don't.
Finally, whenever a document is opened (not created), it could compare its
property values against those in the template, if they are different, you can
either ask the user if he/she wants to update them, or update them
automatically.
You could even add the option "Never ask again" so the document will keep
its properties until the user decides to update them. For such cases, you
could have a button labeled something like "Automatically Update" so that the
userform does not pop-up, but the document properties are updated from those
in the template whenever the user wants to...
As a totally different appraoch, you could use an *.INI file to store those
values...
BUt this implies handling a second file, not just the template... More code
needed and error checking will be more important. E.g. What if the user...
...deletes the *.INI file?
...moves the template, but not the *.INI file?
...etc.
See... the sky's the limit!