
Signature
James III,
Sincere VBA Newbie!
"had me create an 'autonew' macro. Does that name mean anything special?"
Indeed it does. It means exactly what is stated on that page:
"When you create a new document from the template, the autonew macro opens
the user form for the user to input data"
AutoNew - or more currently, Document_New - will display the userform when a
new document is cloned from the template. You have not stated if this is, in
fact, what you are doing.
You can also have a userform display whenever a document is opened (as
opposed to a new document being cloned from a template), using the
Document_Open event.
"I used a command button on the document to populate controls on the userform
with data from the document "
One way, but you could also use the Userform_Initialize event to do this,
with something else (a keyboard shortcut, a button, a menu item) that will
fire Userform.Show.
“An obtuse 'solution' that I proposed is to include in the template an
explanation of how to enter/exit the form fields 'properly' (obviously not
the desired path).”
I am afraid I am going to have to disagree. Users using a document properly
IS the desired path.
That being stated, data validation (as well as top notch error trapping) is
the hardest thing of all to do.
Overall, while I do use formfields, and I do think there are valid uses for
them, I am with Jay on this. DocVariable fields are very handy….except for
the ease of user editing of the values. DocVariables are great for putting
stuff IN, but not very good for getting stuff from the users. On the other
hand, userforms ARE good at getting stuff from users. Far better, IMO, than
formfields. Because you CAN do solid data validation/error trapping much
much easier. So between the two (userform input and DocVariable fields) you
can keep a good grip on the document.
You could put a button on a toolbar (or a shortcut key) that displays the
userform. If there ARE values already existing, the userform fills its
fields with those values. Its OK button – post data validation, or
performing data validation – writes those values.
User wants to change things…they click the button and get the userform again.
In other words, ALL input is done through the userform.
“it appears to me that it would be a significant rework to convert the all of
the steps with text form fields so the data is entered via a userform.”
Yes, it probably would be. However, once done, it would be a more robust
process.
>Hi Jay,
>Thank you for your response. I tried the userform and I can see why you use
[quoted text clipped - 31 lines]
>> >
>> > Any suggestions would be greatly appreciated!
Jay Freedman - 27 Mar 2008 22:34 GMT
I agree with all of fumei's points. I'll just take on the one section that
wasn't addressed yet:
>> then to hide the userform. However, the code I used is in the
>> ...button_click() subroutine. Since I will have numerous steps, it
>> will require a _click() subroutine for each step. Is there anyway
>> to trigger on a mouse click without the associated code being tied
>> to a specific control?
I'm not quite clear on what constitutes a step, but in general you have to
provide an event procedure for every event you want to respond to. That may
be a button click, a character typed or erased in a text box (the "change"
event of that control), entry into or exit from a control, etc. So the
answer to your question is "no".
If you provide helper functions in the userform code, then a lot of these
event procedures will consist of only one or two lines of code that call a
helper function with the proper arguments and then set a value or branch on
the result of the function. An example of a helper function might be one
that takes a value and determines whether it's valid for the current
control, returning a Boolean value (similar to the built-in IsNumeric
function). In addition to the value itself, you can pass limits and other
criteria as arguments.
A lot of these little event procedures can be "written" by copy/paste/small
edit. Also, you can use the two dropdowns at the top of the VBA editor
window for speed: select the control from the left dropdown, select the
event from the right dropdown, and VBA will create the event procedure's
first and last lines for you.
You should also look into the Multipage control, which lets you create more
than one page in a userform and use Back and Next buttons to control
navigation.

Signature
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
>> [quoted text clipped - lots of lines]
>>>>
>>>> Any suggestions would be greatly appreciated!
James III - 28 Mar 2008 22:27 GMT
fumei & Jay,
Thank you for your assistance. It's feels good to not be alone in this
Microsoft Jungle!!!

Signature
James III,
Sincere VBA Newbie!
> I agree with all of fumei's points. I'll just take on the one section that
> wasn't addressed yet:
[quoted text clipped - 33 lines]
> >>>>
> >>>> Any suggestions would be greatly appreciated!