View Full Version : Deploying User Forms from template in Word 2003
will1128
09-03-2010, 02:32 PM
I have a Template and I've created a form which will open several forms.
If I was to distribute the template, how would I guarantee each time a user opened the template they would automatically open my first form (PM_Form)?
User_Form_Template is a screen shot with how the variables would be set up.
Thanks,
Kimberly
P.S. I tried using form fields, but this document will be used over and over and over...and a User Form seemed like my best option.
Tinbendr
09-03-2010, 03:14 PM
In the VBEditor, select ThisDocument. Press F7 (or click icon on far left) to display code for that module.
At the top of the window, select Document. If the New event code is not automatically inserted, click (on the right side) the dropdown and select New.
It should insert the code...
Private Sub Document_New()
End Sub
Then add the userform show.
Private Sub Document_New()
PM_Form.Show
End Sub
will1128
09-07-2010, 08:09 AM
Doesn't your code only work for the current open Word document?
I understand where to place your code, but every time I try to save it Word automatically tries to save it as a Word document and not a template.
So when I try to open it, the form doesn't show, why not?
I've attached an image of the VBA interface with what you suggested.
fumei
09-07-2010, 10:06 AM
1. Tinbendr should have explicitly stated to put the Document_New code in the template ThisDocument. Thus, when the template is called, cloned to a new document, its Document_New event fires.
2. "each time a user opened the template " Oh-oh. I hope that is a minor error in statement. Users should NEVER, EVER, open templates.
The image you posted shows the Document_New in (as you say) the document. It is not supposed to be there. It is supposed to be in the FormONDESKTOP ThisDocument.
IF - again IF - you have the userform .Show instruction in the Document_New event in the template .DOT file ThisDocument module, then yes, every time the user does a File > New (or double clicks the file), a new document is cloned, and yes, the userform will show.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.