Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / April 2006

Tip: Looking for answers? Try searching our database.

Template with a Form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
FGM - 14 Apr 2006 16:26 GMT
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...
John - 14 Apr 2006 18:18 GMT
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

>I am running Windows 2000
> Office 2003
[quoted text clipped - 14 lines]
>
> Thanks for your help...
Greg Maxey - 14 Apr 2006 18:30 GMT
I suppose that you could do what John suggests or then you could put
the macro that calls the form in a an AutoNew routing.  It runs when
your create a new document and it doesn't run when you open an existing
document.

See:
http://word.mvps.org/FAQs/MacrosVBA/DocumentEvents.htm
FGM - 14 Apr 2006 18:43 GMT
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...

> I suppose that you could do what John suggests or then you could put
> the macro that calls the form in a an AutoNew routing.  It runs when
[quoted text clipped - 3 lines]
> See:
> http://word.mvps.org/FAQs/MacrosVBA/DocumentEvents.htm
John - 14 Apr 2006 19:14 GMT
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

> Thanks to both of you ... always amazed...  will try them next week and
> let
[quoted text clipped - 9 lines]
>> See:
>> http://word.mvps.org/FAQs/MacrosVBA/DocumentEvents.htm
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.