#1
|
|||
|
|||
Auto dating a document Data A to Date B
I don’t know if this is possible via VBA or something else. I have a series of word documents ( singing in forms etc ) that I need to print out on a regular basis. The same document is printed out for the whole month/year with just the date changed in every one, is there anyway of automatically changing the date so each one prints out with the date automatically advancing to the next day. I have used fields before where I have printed out stuff today and the date has automatically been changed to tomorrows date but how can this be achieved for say a months’ worth printed out in advance. Ideally what I would like is a pop up box or something where I could enter a start date and an end date and then just hit print, and it would print off x amount of copies with the date advancing a day on every copy. I’ll be extremely grateful for any help offered. |
#2
|
|||
|
|||
Use
Dim i As Long With ActiveDocument .Variables("Date").Value = InputBox("Enter the start Date") .Range.Fields.Update .PrintOut For i = 1 To InputBox("Enter the Number of Days") With .Variables("Date") .Value = DateAdd("d", 1, .Value) End With .Range.Fields.Update .PrintOut Next i End With |
#3
|
|||
|
|||
Thank you for your reply. I can just about work out what the code you provided is doing but I cant get it to work. Does this need a field in the document to work or does the date need to done via VBA. I have made a macro with the code and I have tried with a field like below
{DATE \@ "dddd, d MMMM yyyy"} And just a simple {DATE} But nothing seems to update. I commented out the .PrintOut bits while testing. |
#4
|
|||
|
|||
See Installing Macros.
You need to create a macro and insert this code. You would want a field in your document something like: { DocVariable Date \@ "dddd, d MMMM yyyy" }. The field braces {} cannot be typed, they must be inserted by Word using Ctrl+F9 or by having Word create the field. For more, see Date Calculation Tutorial, especially the introductory material on creating fields. |
#5
|
|||
|
|||
Thank you both for your speedy and helpful replies. I have got it working a treat now sometimes all you need is a kick in the right direction
I don't seem to be able to mark this as solved, no option in thread tools. |
#6
|
||||
|
||||
I've done that.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Auto update excel graph range, ignore data when date reads 00-Month-00 | SavGDK | Excel | 2 | 06-24-2016 08:05 AM |
Auto populate & auto calculate values from other sections in the same word document | Frantic | Word VBA | 2 | 01-24-2015 04:54 PM |
How can a document have the same date modified/create date, yes have have actual file content? | legaleagle | Word | 15 | 01-07-2015 06:58 PM |
Post dating a letter using fields | Just Cruizin | Word | 1 | 05-21-2014 08:27 PM |
Auto Change Date in Word Document??? | dssxxxx | Word | 2 | 01-06-2011 05:50 AM |