Template with a Form

F

FGM

I am running Windows 2000
Office 2003

I have a Word Template that contains a form that pops up when a new document
is being created from the template. The Form is so the user can fill in the
fields that are need for a fax. (I know you can do it in fields without a
form, however, we like the form so much better as you quickly tab through the
form.)

My problem is that when the new word document is saved and then reopened the
form pops up again. We can just close the form but it would be nice that
once the document has been saved the form is disabled. Is this possible?

Thanks for your help...
 
J

John

Hi there,

To stop the form code running you need to have some kind of check that this
is the first time its being called. You could add a string to the document
properties the first time it the document gets opened and then test for that
within the Open event code such as:

Private Sub Document_Open()

Dim DocPropComms As DocumentProperty

Set DocPropComms =
ThisDocument.BuiltInDocumentProperties(wdPropertyComments)
If DocPropComms.Value = "" Then
Call YourFormCode
End If

End Sub

Sub YourFormCode()

ThisDocument.BuiltInDocumentProperties(wdPropertyComments) = "Faxed"
'+ the rest of your code

End Sub


This would at least do what you're after. If you want to go further you
could add some more code to remove the form module (or any other module come
to that) if it's not going to be used again.....................have a look
at Chip Pearson's site below. The code is for Excel but is basically the
same for Word. Might be worth testing it on a copy doc first!

http://www.cpearson.com/excel/vbe.htm

Here's some code adapted from Chip's original:

Sub RemoveCodeModule()
'Requires reference to "Microsoft Visual Basic
' for Applications Extensibility 5.3"
Dim VBComp As VBComponent
Set VBComp = ThisDocument.VBProject.VBComponents("YourFormName")
ThisDocument.VBProject.VBComponents.Remove VBComp
End Sub

Hope that helps.

Best regards

John
 
F

FGM

Thanks to both of you ... always amazed... will try them next week and let
you know.. Greg's seems easiest and so will try that but will look at the
other .. it looks a little beyond my abilities but learn from seeing.
Thanks so much...
 
J

John

Hi, I wasn't aware of the Auto option (very interesting, thanks Greg) and
it seems to be a better solution to your problem.

Anyway, have a good weekend.

Best regards

John
 

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