#1
|
|||
|
|||
Add days to Saved date in Word
Hi there,
I'm trying to add 14 days to the saved date of a Word document but I'm unable to, weird as it seems very strait forward. I'm following this web page: http://www.gmayor.com/insert_a_date_...than_today.htm as guide for the actual date, but the formula {={Date \@ "dd"}+14} isn't working, when I open the document I see nothing. I'm entering both curly brackets groups by Ctrl + F9. It only works when I enter {date} or {savedate} |
#2
|
|||
|
|||
If the date were the September 21, your formula would give you September 35.
Here is the field for 14 days from the CREATEDATE: { QUOTE "{ SET " Delay" "14" } { SET "DaysInMonth" { IF { CreateDate \@ "MM" } <> 2 { = ROUND(30.575*{ CreateDate \@ "MM" },0)- ROUND(30.575*{ = { CreateDate \@ "MM" } -1 },0) } { IF { = MOD( { CreateDate \@"yy" } , 4 ) } > 0 "28" "29" } } } { SET "NextMonth" { IF { CreateDate \@ "MM" } = 12 "1/97" "{ = { CreateDate \@ "MM"} + 1 }/97 } } { IF { = { REF "Delay" } + { CreateDate \@ "dd" } } <= {REF"DaysInMonth"} {CreateDate \@ "MMMM { = { REF "Delay" } + { CreateDate \@ "dd" } }, yyyy"}{ QUOTE { NextMonth \@ "MMMM" } { = { REF "Delay" } + { CreateDate \@ "dd" } - { REF"DaysInMonth" } }, { IF { CreateDate \@ "MM" } <> 12 { CreateDate \@ "yyyy" } { CreateDate \@ "{ = 1 + { CreateDate \@ "yyyy" } \# "xxxx" }" } } } }" } See Date Calculation Tutorial. Read the introductory parts and then find the field construction you need in the tutorial. You can simply copy it from the tutorial and paste into your document. Calculated Dates in Microsoft Word using Fields or vba (This is the page I copied the field from.) |
#3
|
|||
|
|||
Thanks Charles, what a big amount of code
Copy and paste and first curly braces with Ctrl + F9 don't work, should I create all curly braces with Ctrl + F9? |
#4
|
|||
|
|||
Go to the tutorial. Do not try to reconstruct that field!
The tutorial is a Word document. You can take a field in that document, copy it, and paste it into your own document. Then you can change it to suit. For instance: CreateDate -> SaveDate Delay = 14 -> Delay = 21 Yes, all curly braces must be inserted using Ctrl+F9, in pairs. Reconstructing that field manually is virtually impossible. Also, spaces added to make it more readable may change how the field behaves. If you do not want to use Paul Edstein's tutorial (which you should), you can download an Add-In that will create a field for you from this site: http://web.archive.org/web/201110310...ed%20Dates.htm That was the original source of the field on my web page. Paul spent a great deal of effort and used expertise few possess to write his tutorial. I would advise using it. You will tear your hair out trying to write fields that are freely available in the tutorial.Date Calculation Tutorial If you just want the field I posted above, go to my page Calculated Dates in Microsoft Word using Fields or vba and use the link on that page to download a file that contains that field. I recommend using Paul's instead, though. His tutorial includes a good discussion on how to copy and paste them as well as about formatting differences. Once you have downloaded Paul's tutorial, you can experiment and learn how these fields work if you want. Here are some of his other tutorials on fields: Microsoft Word Field Maths Tutorial Word Fields and Relative Paths to External Files This stuff is neither straightforward nor simple. It does follow rules but discovering those rules can be a painful process. I feel happy just being able to use a field someone else has constructed and manipulate it to suit my needs. If needed, there are macros available online (Graham's site) that convert field codes to text and back. Again, because of spacing issues, those would not work with the field I posted above. www.gmayor.com/export_field.htm www.gmayor.com/export_field.htm#TextToField |
#5
|
|||
|
|||
Thanks again Charles, but I seem not able to copy and paste to my document.
In the tutorial, I see the field quotes with Alt + F9, but I'm not able to see the whole formula, as If I right click and Edit formula, it only gives me the line I clicked. Also, normal copy and paste of the quote don't work, it shows me the exactly quote code in Word, and in Notepad++, it shows the value (result) of the quote. How do I copy and paste the quote to my document? Should I enter the value on the formula field when inserting quick part (field)? |
#6
|
|||
|
|||
OMG, sorry for confusion, I was seeing the quotes as I previously clicked Alt + F9..
|
#7
|
|||
|
|||
By the way, I would recommend using the CreateDate rather than the SaveDate. This should be in a template. You should not be opening documents and changing them to use them.
Using Date Fields in Microsoft Word Alt+F9 is a toggle and applies system-wide. Its effects will persist through closing and reopening Word. It changes a Word option. |
#8
|
|||
|
|||
Thanks for the info Charles, but I'm using the Word document within MS Dynamics CRM, and the createdate it's when it was uploaded to CRM, so the savedate, will be updated always when users download the document, isn't it?
I have modified the code to show date in format dd/MM/yyyy, but I can't paste here. Should I upload a word document? |
#9
|
|||
|
|||
Quote:
If you use a template and people use the template to create a new document, the createdate is the date the new document is created. Savedate is a bit tricky in that the date is not updated until after the document is saved and may have to be manually updated depending on where in the document the field is kept. Simply saving the document is unlikely to update or change the field. Templates in Microsoft Word Quote:
If the source of your field is Paul's tutorial, refer to the section of the tutorial you used as a source. Last edited by Charles Kenyon; 09-22-2016 at 11:53 AM. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Inserting a formula to count 30 days before and after a date in WORD table | bjh894 | Word | 9 | 05-18-2020 11:14 AM |
Date field - future date calculation + only business days | neon4 | Word | 7 | 01-21-2016 02:21 PM |
adding days to a date | euterpia | Excel | 1 | 01-18-2016 07:42 AM |
How do I get auto-updated "number of days since specified date" on MS word? | terry795 | Word | 16 | 01-07-2016 04:33 PM |
Date Field to add 10 Days to Current Date | Erbwon | Word | 6 | 11-12-2012 06:17 PM |