PDA

View Full Version : Solved: UserForm not working when saved as template.



view
09-09-2009, 02:30 AM
Hello all,

As a disclaimer, I may be confusing some of the terminology for the file types and their intended uses so I apologise in advanced.

I've got a word document in which I've created a UserForm with various text boxes etc which you fill out. The contents of the form are then used to 'populate' the document (replacing bookmarks with the text in the form).

Satisfied with all the VBA (largely thanks to help provided on this forum!), I saved the .doc as a template. (Note - My colleagues and I are running Word 2002 SP3)

I closed word, navigate to the folder and open the template. After enabling macros, I'm then presented with the form and everything works fine.

However - I logged on to a different machine in the office, navigated to the folder (shared drive) and opened the template. I'm prompted to enable macros, which I do, but then nothing happens.

I opened up the VB Editor (Alt + F11), expanded the "Form" section in the project window and all the VBA for my form is there. The sub to show the form on a new document is there.

Any thoughts on what is going wrong? At the moment I can't upload the file (contains a small amount of confidential information) but if more details are needed I'll clean it up.

I saved it as a template so that when the other staff open it up it generates a new document with no risk of over-writing the original.

Any help with this would be greatly appreciated.

lucas
09-09-2009, 08:37 AM
navigated to the folder (shared drive) and opened the template

It sounds like you are doing everything right as far as I can tell but what does the above mean exactly? Does it mean that you browse to the file and double click on it or are you opening word and browsing to the file through file - open?

view
09-09-2009, 11:38 AM
I can honestly I say I can't remember which way I tried it!

I assume from your question that it makes a difference?

lucas
09-09-2009, 11:42 AM
Yes, if you only have a document new procedure then if you browse to the file from word and actually open the template file then it wont run because you haven't created a new document. You have opened the template.....

It would run if you also had a document open procedure but that is not what you want if you plan to use it as a template.

try double clicking on the template on the network and see if it runs.

lucas
09-09-2009, 11:44 AM
When the file is open, look at the very top and see what document is open.

If it says document 1 or some such then it is a clone of the template.

If it says something.dot with a .dot file extention then you have the actual template open and the code will not run because your code to initialize the form is in a document new procedure....

Hope I'm making sense.

view
09-09-2009, 04:43 PM
Ah that makes perfect sense. Thank you Lucas. Will check it tomorrow and report back if that resolves the issue.

view
09-14-2009, 02:01 AM
Thank you Lucas - you correctly identified the problem. :) Issue is now resolved.