Simple way to time stamp pages when printing?

J

JohnH.

Hi, Is it possible to configure Word 2003 or 2007 automatically
timestamp documents when printing. I know I could do this by adding a
header or footer to a document with a datetime field set to auto
update. I'm looking for a method that is document independent that
will simply print the date and time at the bottom of every page or as
a watermark on every page printed.

I've researched this pretty thoroughly. Either I'm not thinking about
this is the right context (I hope), or there is just not a simple way
to do this?

Thanks,
John
 
G

Guest

There is not a simple way to do it.

You would need a macro in the Normal.dot template to (a) insert a properly
formatted date/time field in the footer, (b) print the document, and (c) run
the Undo command to remove the field. It may also be necessary to set the
document's Saved property to True to avoid a request to save it.

You can assign a separate menu item and/or toolbar button and/or keyboard
shortcut to this macro, or you can name the macro FilePrint to intercept the
built-in command. If you do the latter, you also want to make a macro named
FilePrintDefault to intercept the standard Print button.
 
J

JohnH.

Thanks Jay. This gives me a conceptual starting point. I've been
writing code in various dialect of c/c++/c# for 20 years. But, I've
never developed anything for Word. It's a surprising complex
application to develop for. I'm hoping once a tackle a few basic
concepts it will seem easier.

Thanks,
John
 
G

Graham Mayor

Simple? The problem with simple methods is that they make no allowance for
what might already be in the footer of the document, however the following
macro will attempt to add
Printed: - 02/05/2007
to the end of the footer of the document, print the document then close it
without saving that addition (which is what appears to be wanted).

As the document is going to be closed without the added date, the macro also
forces a save before doing anything else so that your changes are not lost.

You could use the macro to intercept the print command, but I would urge you
not to, as that would work for all documents irrespective of whether it will
screw up the footer that already exists and thus the alignment of the
document.

You can change the date and text formatting as required

Dim strView As String
ActiveDocument.Save
strView = ActiveWindow.View.Type
ActiveWindow.View.Type = wdPrintView
ActiveWindow.View.SeekView = wdSeekCurrentPageFooter
With Selection
.EndKey Unit:=wdStory
.Font.Name = "Arial"
.Font.Bold = False
.Font.Italic = True
.Font.Size = "10"
.TypeText Text:=vbTab & "Printed: - "
.InsertDateTime DateTimeFormat:="dd/MM/yyyy", _
InsertAsField:=False
End With
ActiveWindow.View.SeekView = wdSeekMainDocument
ActiveDocument.PrintOut
ActiveWindow.View.Type = strView
ActiveDocument.Saved = True
ActiveDocument.Close

See http://www.gmayor.com/installing_macro.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
G

Guest

Graham:

Great code; hope you don't mind if I copy it to my swipe file. I'll probably
add a Yes/No/Cancel message box before the first save -- in case I've made
some temporary changes and want to print the document without saving those
changes.

Bear
 
G

Graham Mayor

By all means use the code, but already you are beginning to see the snags
with this type of application ;)

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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