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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

capturing the print event in Word

Status
Not open for further replies.

davefish

Technical User
Jul 26, 2002
169
GB
I wish to ensure that a file is saved prior to printing, but cannot find the event to trigger a procedure based on the documeny print dialogue box being launched from the File drop down menu. Can anyone help?

DaveFish
 
Rewrite the FilePrint command, like this: Or something like this. You may need to do some adjusting.

Code:
Sub FilePrint()
If ActiveDocument.Saved = False Then _
   ActiveDocument.Save
' then your print parameters
' adjusted for your needs
   Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
      wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
      ManualDuplexPrint:=False, Collate:=True, Background:=True, PrintToFile:= _
      False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
      PrintZoomPaperHeight:=0
End Sub
this redirects the, well File Print command to this procedure, which in turns makes sure the file is saved before printing.

Gerry
 
Gerry,

Thanks for the lead. I'll try it in the next few hours and get back to you if there's a problem

Dave
 
Gerry,

Sorry ,perhaps I didn't explain myself so here goes for a fuller description.

I have a template which is already named Q123_Temp.doc, when this is launched a mail merge pulls a customer address from our CRM program and some text is changed.

The next step is to save-As under a reference name which populates a field on the document with the saved name, activated when the print is intiated.

Its then printed and saved again. What I'm trying to is ensure the name is changed at the point of printing, as we've had a few instances where it's not been saved and the template file name "Q123_Temp.doc" ends up as the customer filename. I need to get hold of an event when the File_Print button is clicked.

Any ideas?

Dave
 
1. Sub FilePrint() IS, repeat IS, the event when the File Print button is clicked. Don't how to say that any other way. As stated, this rewrites the command.

2. No, you were not clear, and part of it is still not. Do you want the SaveAs performed prior to attempt at printing? Why are you suggesting a SaveAs, a print, then a save again???
to save-As under a reference name which populates a field on the document with the saved name, activated when the print is intiated.

Its then printed and saved again.

To repeat, the FilePrint Sub IS the print command. So put whatever you want in there, before the actual printing istructions. You can also have it do your saving action, then just display the Printing dialog. It does not have to perform specific instructions regarding printing.

Code:
Sub FilePrint()
ActiveDocument.SaveAs Filename:=[i]string of file name (path?) from your field[/i]
   Application.Dialogs(wdDialogFilePrint).Show
   ActiveDocument.Save
End Sub
would do a SaveAs with the filename from your field, show the print dialog, and when finished with that, save the file again.

Gerry
 
Hi Gerry,

I have inherited a document system which uses Word documents as opposed to templates. The first SaveAs is to change the 'Golden copy' to the specific customer name. The action of printing envokes an update of fields embedded in the document, hence when printed the document has the cusomer name in the referecne field. The document doesn't havge to be saved again, but it is, to a different location.

I'll try your code again as you suggest

Dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top