Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-04-2016, 01:46 PM
gthemean gthemean is offline Auto dating a document Data A to Date B Windows 7 64bit Auto dating a document Data A to Date B Office 2010 64bit
Novice
Auto dating a document Data A to Date B
 
Join Date: Jul 2016
Posts: 3
gthemean is on a distinguished road
Default 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.
Reply With Quote
  #2  
Old 07-04-2016, 11:24 PM
DougMVP DougMVP is offline Auto dating a document Data A to Date B Windows 7 32bit Auto dating a document Data A to Date B Office 2010 32bit
Advanced Beginner
 
Join Date: Nov 2013
Posts: 50
DougMVP will become famous soon enough
Default

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
Reply With Quote
  #3  
Old 07-05-2016, 10:29 AM
gthemean gthemean is offline Auto dating a document Data A to Date B Windows 7 64bit Auto dating a document Data A to Date B Office 2010 64bit
Novice
Auto dating a document Data A to Date B
 
Join Date: Jul 2016
Posts: 3
gthemean is on a distinguished road
Default

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.
Reply With Quote
  #4  
Old 07-05-2016, 12:52 PM
Charles Kenyon Charles Kenyon is offline Auto dating a document Data A to Date B Windows 8 Auto dating a document Data A to Date B Office 2013
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,140
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

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.
Reply With Quote
  #5  
Old 07-05-2016, 02:59 PM
gthemean gthemean is offline Auto dating a document Data A to Date B Windows 7 64bit Auto dating a document Data A to Date B Office 2010 64bit
Novice
Auto dating a document Data A to Date B
 
Join Date: Jul 2016
Posts: 3
gthemean is on a distinguished road
Default

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.
Reply With Quote
  #6  
Old 07-05-2016, 06:59 PM
macropod's Avatar
macropod macropod is offline Auto dating a document Data A to Date B Windows 7 64bit Auto dating a document Data A to Date B Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by gthemean View Post
I don't seem to be able to mark this as solved, no option in thread tools.
I've done that.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto dating a document Data A to Date B Auto update excel graph range, ignore data when date reads 00-Month-00 SavGDK Excel 2 06-24-2016 08:05 AM
Auto dating a document Data A to Date B Auto populate & auto calculate values from other sections in the same word document Frantic Word VBA 2 01-24-2015 04:54 PM
Auto dating a document Data A to Date B 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
Auto dating a document Data A to Date B Post dating a letter using fields Just Cruizin Word 1 05-21-2014 08:27 PM
Auto dating a document Data A to Date B Auto Change Date in Word Document??? dssxxxx Word 2 01-06-2011 05:50 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:37 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft