Adding 'Printed at time & date' to document

M

Mark

Is there a way with code using the default print command in word that the
text 'Printed at system time & system date' can be added to the footer of a
document?

If so, would someone be kind enough to supply me with the relevant code,
Please?
 
D

Dave Lett

Hi Mark,

You can include the following in the document without using VBA.

Printed at { DATE \@ "M/d/yyyy h:mm am/pm" }

The {} signifies a field. The result of this field is 8/24/2006 9:02 AM

HTH,
Dave
 
J

Jezebel

PRINTDATE would be a better field to use.



Dave Lett said:
Hi Mark,

You can include the following in the document without using VBA.

Printed at { DATE \@ "M/d/yyyy h:mm am/pm" }

The {} signifies a field. The result of this field is 8/24/2006 9:02 AM

HTH,
Dave
 
G

Greg Maxey

Mark,

Thanks to fellow newsgroup contributors Jonathan West and Jezebel, I
just recently learned to use event handlers. There is one called
documentbeforeprint.

I would insert a bookmark in the footer where you want your print data
to appear. Lets call it "PrintData."

Create a class module. Name it myClass. Insert this code:

Option Explicit
Private WithEvents mWordApp As Word.Application
Private Sub Class_Initialize()
Set mWordApp = Word.Application
End Sub
Private Sub mWordApp_DocumentBeforePrint(ByVal Doc As Document, _
Cancel As Boolean)
Dim oRng As Word.Range
Set oRng = ActiveDocument.Bookmarks("PrintData").Range
oRng.Text = "Printed at: " & Time & " " & Date
ActiveDocument.Bookmarks.Add "PrintData", oRng
End Sub

In a project module initiate the class module when the document opens
using this code:

Option Explicit
Dim X As myClass
Sub AutoOpen()
Set X = New myClass
End Sub
 
G

Greg Maxey

In this case Dave and Jezebel's suggestions for using a field is
probably better. I suppose I was so thrilled at the opportunity of
sharing my new found knowledge that I didn't see the forrest for the
tree.
 
J

Jean-Guy Marcil

Greg Maxey was telling us:
Greg Maxey nous racontait que :
In this case Dave and Jezebel's suggestions for using a field is
probably better. I suppose I was so thrilled at the opportunity of
sharing my new found knowledge that I didn't see the forrest for the
tree.

lol

Also, if fields are not appropriate for some reason, it would still be
easier to highjack the FilePrint and FilePrintDefault subs...

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

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