Microsoft Office Forums

Go Back   Microsoft Office Forums > Microsoft Word > Word

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 11-08-2012, 04:37 PM
Erbwon Erbwon is offline Windows Vista Office 2007
Novice
 
Join Date: Nov 2012
Location: Huntington, New York
Posts: 5
Erbwon is on a distinguished road
Default Date Field to add 10 Days to Current Date

I am using Microsoft Word 2007 and trying to find the code that will allow the creation of a date field to add 10 days to the current date. This document will be uploaded for many users to access, so it must also update this date automatically based upon the date the document is opened. I've used the DateCalc file located at http://www.gmayor.com/downloads.htm#Third_party which does seem to work for me, although it does not update automatically when opening the document from day to day. I physically have to highlight the field and right click Update Field to get the current date plus 10 days out. Is there any way to make this date field update automatically based on the date the document is opened? Or is there a different method to do this? Any help would greatly be appreciated. Thanks in advance.
Mike
Reply With Quote
  #2  
Old 11-08-2012, 05:24 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,390
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

Hi Mike,

You could force the field to update upon opening via a Document_Open macro, but having such a macro may cause issues for your users - for security reasons, some may not have macros enabled and others may be unwilling to let a macro in a 'foreign' document run.
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #3  
Old 11-09-2012, 08:16 AM
Erbwon Erbwon is offline Windows Vista Office 2007
Novice
 
Join Date: Nov 2012
Location: Huntington, New York
Posts: 5
Erbwon is on a distinguished road
Default

Unfortunately I cannot use macros in this document. Is there any other way to make the date automatically update? Or is it possible to create a date 10 days in advance from when the document is opened any other way? Maybe not using a field or a different code within the field?

Last edited by Erbwon; 11-09-2012 at 12:37 PM.
Reply With Quote
  #4  
Old 11-09-2012, 12:55 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,390
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

Sadly, there is no other way. Your users can set Word to update fields before printing, to ensure their printouts are updated, but there's nothing you can do at the document level without a macro to guarantee even that.
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #5  
Old 11-09-2012, 01:34 PM
Erbwon Erbwon is offline Windows Vista Office 2007
Novice
 
Join Date: Nov 2012
Location: Huntington, New York
Posts: 5
Erbwon is on a distinguished road
Default

How would I go about setting up the macro? And will all users need to habe macros enable for them to open the document correctly?
Reply With Quote
  #6  
Old 11-09-2012, 02:23 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,390
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

Assuming the field is in the body of the document, the macro is nothing more than:
Code:
Private Sub Document_Open()
ThisDocument.Fields.Update
End Sub
To install it for use, press Alt-F11 to open Word's vb editor. On the left had side of the screen, you'll see a panel containing your document's name and, below that an entry named 'ThisDocument'. Double-click on 'ThisDocument', then paste the above code into it. Press Alt-F11 again to return to the document, then save it. That's all there is to adding the macro to your document.

And yes, all users would need to have Word configured appropriately. For Word to be able to run macros, go to Word Options|Trust Centre>Trust Center Settings and select the 'Disable all macros with notification' option. That will cause Word to ask for permission before allowing macros in a document to run. This setting applies to all documents, except those opened from what Word 2007 & later call 'trusted publishers, 'trusted locations' and trusted documents' (none of which generate the prompt). The dialoge box that opens when you clicked on 'Trust Center Settings' has entries for these as well, but you probably don't need to worry about any of their settings.
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #7  
Old 11-12-2012, 06:17 PM
Erbwon Erbwon is offline Windows Vista Office 2007
Novice
 
Join Date: Nov 2012
Location: Huntington, New York
Posts: 5
Erbwon is on a distinguished road
Default

Thanks for your help, the macro worked perfectly on my end, I still need to test out the document after I upload it to confirm it works correctly for all my users.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Meaning of current date vs status date when saving baselines ketanco Project 1 02-08-2012 02:20 PM
Set calendar alarm x days before end date el_ja Outlook 2 01-19-2012 10:09 AM
30+ days Variable Day Date Calculations via Fields ztag Word 2 01-06-2012 11:12 AM
How to call current PC date and/or current PC year KIM SOLIS Excel 2 11-04-2011 06:09 PM
Creating an Auto-Calc'd Date? Today+7 Days? SoCalTelephone Word 0 10-06-2010 10:27 AM


All times are GMT -7. The time now is 10:27 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
MSOfficeForums.com is not affiliated with Microsoft