Microsoft Word Form: Save Form, Not Controls or Macros

R

Reggie

Hello,
I have a Word template that consists of a 2 pages worth of form fields,
and 1 page that has the controls used to fill in the form. The
arrangement works well enough, and allows the user to edit the form
manually if the source data is incorrect. I've even figured out how to
save the last 2 pages of the document to a file without the controls.

However, I'm having a problem saving the form without the VBA code
being included. I don't want my users getting confused by the "Macros
anybody?" dialog popping up everytime a completed form is open. So, my
question is how do I save the document without the VBA code being
included in the resulting file?
 
D

Doug Robbins - Word MVP

Save the form as a template in their templates folder and then have them use
File>New and select that template as the basis of the document. Your page
with the controls should probably be a userform however, not a page in the
document

See the article "How to create a Userform" at:

http://word.mvps.org/FAQs/Userforms/CreateAUserForm.htm

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
R

Reggie

I followed the Userform example, and I've changed to using a template
file. However, I'm still getting the "Macros, anybody?" dialog when
opening a doc file saved after creating a new document from the
template. Is there a way to get rid of whatever code is in the
document so that I'm not getting this dialog?
 
J

Jay Freedman

Does your form include controls from the Control Toolbox? If so, those
are the culprit.

When you save a document that's based on a macro-containing template,
the macros are _not_ saved in the document.

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

Reggie

Understood, I tried it with a blank document without the form, and it
worked as you said it would. However, I am running into a different
problem with this project.

This form will operate in a multi-user environment so I want to save
the Template file to my company LAN. However, saving the template
anywhere outside the default folder prevents the code that
automatically opens the userform does not run. I can't save the
template in every user's default template folder.

How do I get the "document_new()" code to run when I save the template
outside of the default "template folder"?
 
J

Jay Freedman

Save the template in a folder on a public share. In Word, go to Tools >
Options > File Locations and set the Workgroup Templates location to point
to that folder. Each user will have to make the same setting. Each user
should also go to Tools > Macro > Security > Trusted Publishers and check
the box for "Trust all installed templates and add-ins".

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

Reggie

Thanks for your help Jay and Doug. I hope Microsoft is compensating
you guys well because you deserve it. I hope that the next version of
Office has a better way to do this. I don't like having to make (or
count on) my users doing set up work. So, why am I doing this in Word
you ask; I don't have a choice. the orginal form is in Word, and I'm
just trying to make my job easier. I'll stop whining now, and get to
work.
 

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