Check user who prints certain docs

J

Johnniec

Hi,

I've done a trawl through the newsgroup and have been unable to find any
help....

I have a macro which sends info to a text (.txt) file (i.e. the users
network login account number plus date & time) when a Doc is opened and/or
closed but what I would like to be able to do is send that same info but
this time would show when the file is printed out.

Can any kind soul send some VBA code which would do that (or point me in the
right direction....)

Many thanks

Johnnie
 
J

Jay Freedman

Hi, Johnnie,

You need two macros (see
http://www.mvps.org/word/FAQs/MacrosVBA/InterceptSavePrint.htm).

One named FilePrint will intercept the File > Print command and its Ctrl+P
shortcut, which shows the Print dialog:

Public Sub FilePrint
If Dialogs(wdDialogFilePrint).Show = -1 Then
' code here to write to the text file
End If
End Sub

The other, named FilePrintDefault, will intercept the Print button on the
toolbar, which doesn't show the dialog:

Public Sub FilePrintDefault
ActiveDocument.PrintOut Background:=False
' code here to write to the text file
End Sub

If you have Word 2000 or later, you can use the DocumentBeforePrint event
procedure as explained the in the article. In that case you just replace the
comment "your code here" with the code to write to the text file.
 

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