Word 2000 - Printdate

A

Ashley Brewin

How do I add days to the printdate? I have to insert a
statement into my documents that says:
"Do not use this document after {printdate +15}"
For example: If I print the document today (16 Oct 03), I
want the date in the statement to show 31 Oct 03.
Inserting the print date is easy enough, but how can I add
15 days to it?
 
J

Jay Freedman

Hi, Ashley,

It's very difficult to do this with a field, because fields don't know date
math (think about what result you should get if the print date is 24 Dec
2002, or 20 Feb 2000). There is a macro at
http://www.chriswoodman.co.uk/Delayed Dates.htm that makes an extremely
complicated nested field.

Alternatively, you can use a small special-purpose macro to insert the
printdate + 15 days as text at a bookmark. Make sure there's a bookmark
named expiredate in the document, and then run this macro:

Sub PrintDatePlus15()
Dim PrintDate As Date
Dim LaterDate As Date
Dim stringLaterDate As String

On Error Resume Next
PrintDate = ActiveDocument.BuiltInDocumentProperties( _
wdPropertyTimeLastPrinted)
LaterDate = DateAdd("d", 15, PrintDate)
stringLaterDate = Format(LaterDate, "dd MMM yy")
ActiveDocument.Bookmarks("expiredate").Range.Text = _
stringLaterDate
End Sub

You can change the format to your liking, and you can use a different
bookmark name if you also change it in the macro.
 

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