Word 2002 - userform

R

R1C1

I have a document template that opens to a userform which in turn fills
bookmarks. The resulting document1 contains the userform and code also. Is
there a way to delete the userform and code module using vba or save a copy
without the code and forms in it?

Thanks much from a Word rookie.

Alan
 
J

Jay Freedman

The proper way to use Word is to create form and its bookmarks _and_
the userform and code in a template (*.dot file), which you then
choose in the File > New dialog to create a new document. The
resulting document will contain the bookmarks, but it won't contain
the userform or code.

Read http://www.word.mvps.org/FAQs/Userforms/CreateAUserForm.htm for
more background.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 
R

R1C1

Thanks for your reply. After reading through your reference and looking
through my template I realized that my problem wasn't as described. In the
VBE, when I open the created document the original template Project becomes
visible in the Project window along with the new document Project. The new
document has a Reference to the template, but not any code. Would you know
what I might of done to create this reference which is opening the template
Project? When the new document is opened, I do get the macro enable window
which tells me the reference is actually opening the template (but the
template is not visible). The code I was seeing is actually in the template
Project, not in the created document.

I appreciate your help.

Alan
 
J

Jonathan West

R1C1 said:
Thanks for your reply. After reading through your reference and looking
through my template I realized that my problem wasn't as described. In the
VBE, when I open the created document the original template Project
becomes visible in the Project window along with the new document Project.
The new document has a Reference to the template, but not any code. Would
you know what I might of done to create this reference which is opening
the template Project? When the new document is opened, I do get the macro
enable window which tells me the reference is actually opening the
template (but the template is not visible). The code I was seeing is
actually in the template Project, not in the created document.

That is the way Word normally works - macros, toolbars & other stuff from
the template is available to a document based on it. If you definitely want
to make it unavailable, then as the last action of the macro that puts the
form details into the document, set the document's AttachedTemplate property
to the NormalTemplate object.
 
R

R1C1

Thank you for your help Johnathan. I see I really need to hit the books
before I go too far with Word.

After reading up on your suggestion, I see that once the file is transferred
to another computer, which doesn't have the template, it loses the
AttachedTemplate properties and attaches to the NormalTemplate object. I was
concerned that I was passing on a document that would require enabling
macros, but that is not the case since the template is strictly internal.

Thanks again,

Alan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top