Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to print and at the same time save a WORD fill-in form 3

Status
Not open for further replies.

helmark

Technical User
Sep 2, 2004
7
TT
Hope someone in this group can help me.
I have created a fill-in form for my home business,and named the document "Home & Garden Management" in MS WORD 2000. I would like to have MS Word 2000 automatically save a copy of the form to a predesignated folder on my C:\drive when fill-in data is completed, and at the same time print out a copy to the client for their signature.

I am totally new to layout techniques, and feel proud that I was able to design and create such a document. It would therefore be an asset to me if there is some way I can have a macro save each completed form so that I have an archive both on my hard drive and on paper before it prints it out. As the data on each client is different, I don't want to have to remember to manually save before I print each time.

Could you give step-by-step explanation on how to go about it as I am still in the creeping stages.
Hope this is the correct forum for my question, and that my wish is possible. Please help
Thanks a bunch.
 
What you ask for is very possible. I am not sure exactly how your "fill-in" form is designed. So I am going to assume you are using FormFields. if you are not, and are doing something else (ActiveX controls, or {ASK} fields - please post back here.

Essentially, you are asking for two things to happen.

1. Save the document to a specific lcation. make a Copy you state. Fine, then you want the FileSaveAs command.

2. Immediately Print this document.

Version 1
Code:
Sub SaveAs_Print1()
ActiveDocument.SaveAs FileName:="[i]filename_and_path[/i]"
ActiveDocument.PrintOut
End Sub

This does the two steps. You could have this as the OnExit macro for the last formfield. as soon as the user moves through that last formfield, the macro will fire, and voila, the document will be saved, and printed.

Version 2
Code:
Sub SaveAs_Print2()
Dim response
Dim msg As String
msg = "Are you sure all the information is correct?"
response = MsgBox(msg, vbYesNo)
If responses = vbYes Then
    ActiveDocument.SaveAs FileName:="[i]filename_and_path[/i]"
    ActiveDocument.PrintOut
Else
End If
End Sub

This version asks for confirmation that all the information is acceptable, THEN saves and prints.  If the user decides no, nothing happens.  They are returned to the document.

Either of these could also be placed as a button on a toolbar.  Clicking it would runit.  They could be placed as a ActiveX command button right in the document - clicking it would run it.  Having it automatically run is, I believe a better way to go.

If you are using Formfields, go to the last one, and (with the document unprotected) right click it.  Select Properties, and select the macro as "Run macro on:"  Exit.

Alternatively, you could have the macro run as the Document_Close event.  When the user closes the (original - but changed) document, the macro would instead do the SaveAs, and Print.

If you give a few more details of your document, a more detailed solution would not be difficult to describe.

Gerry
 
Hello Gerry,
Thanks for your most prompt reply and patience.

So far,I've tried your suggested code 1, and it worked, apart from the fact that when it saves it overwrites the information on the previously saved document.

I've thought it over, and found that a better idea would be, to have the macro save the document by client's name,or maybe by an automatically generated number. So that there would be a file on every individual client and at the same time, print out 2 copies for signature.

My form is made up of text form fields.

Thanks a big bunch
 
It does not overwrite the previously saved document. It does a saveas, which creates a new file that is a duplicate, but with a different filename. If the information is different, it would be because the user changed it.

That is what was asked for. Well not really. You asked for it to save a copy, which this does, using file saveas.

Now, if the document has previously information in the text formfields, then someone else has filled in those fields previously. When the next users enters information into the document, the form field values are going to change, if the user enters new information, or not, if they do not.

What precisely are your design requirements?

1. Is this a document that is to used for individual data? Then every one SHOULD be different (as this does).

2. Do you want the form fields to be cleared for each user?

3. Picking up the username is easy, and yes, that is a good way to track files.

Gerry
 
Hi Gerry,
Thanks for prompt reply

Can I e-mail you an example of my form ?, wouldn't like to post it here for the world to see. That way you can see what it looks like. ?

to answer you questions:-
1. Yes, document to be used for individual data
2. Yes, wish for form fields to be cleared after each
fill in of client data.
3. Yes please, I rather like idea of saving by username.
It would be easier to track contract by client in a
folder.
 
Hi Gerry,
With a little persistance, I painstakingly tried out the different codes you gave and "Voila" !. They are working now.
You have been a fantastic help, and I owe you lots of thanks.
With regard to my last post, if you have suggestions to it, you can post them anyway. Maybe they can be useful at a later date.

Thanks a million once again,
Have a great weekend.

Helmark
 
Gerry gets a star from Anne for his promptness and patience.

He's a gem, right, Helmark?

The BEST!
Well, okay, so there's lots of "THE BEST"s in here...

Excel VBA Certification is Finally Here!
 
Yep Dreamboat, you're sure right about that
Big star to Gerry

Helmark
 
helmark, generally they do not like people to post personal email addresses here at Tek-Tips. I posted mine before and was asked not to. The reason is spammer trolling.

I would be happy to give some suggestions on your document. So, what to do?

I am available to private messages at VBA Express. You could check them out:

Actually you should check it out regardless.

Or we could play a riddle. It is Gerry and if you think of chivalry and horses (and who rides them) and Google on that, you can find an artist's site, which is me. Email me there. And sure I would take a look at a file.

Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top