![]() |
|
#1
|
|||
|
|||
![]() I have a document that I have various dates that needs to be selected by the user (will be protected so no editing on their behalf). I want to be able to choose 1 date, it should then pull through to other places. I got the "publish date" in quick parts, so I get that to work. However, I have another set of dates that should be a year later (expiry date) and this should be automatically populated by choosing the first date (publish date). As Quick Parts only have 1 date one I can't seem to create another date nor get the "fields" to work as read in other posts. Please could you advise me on how to get the date to automatically populate by selecting the "publish date". |
#2
|
||||
|
||||
![]()
See http://www.gmayor.com/insert_a_date_...than_today.htm and in particular the link there to Paul's excellent work on date calculations, which you can download and copy the relevant structures to your document.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
|||
|
|||
![]()
I am still struggling to get the 'formula' to work. I want to be able to choose a date on the document (so using a drop down list) and then the expiry date should automatically populate to be a year from now less 1 day. Could you write the exact code (or explain what each line item is for) to be able to do this?
I can send you the file in order to assist? |
#4
|
||||
|
||||
![]()
Attach the file (or you can send it to me at supportATgmayor.com, but if you do so ensure that your forum username is in the message subject or it will be discarded).
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#5
|
|||
|
|||
![]()
Thank you gmayor! Attached find the document.
|
#6
|
||||
|
||||
![]()
OK. Add the following to the ThisDocument module of the document
Code:
Option Explicit Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean) If ContentControl.Title = "Issue Date" Then If Not ContentControl.Range.Text = ContentControl.PlaceholderText Then ActiveDocument.SelectContentControlsByTitle("Expiry Date").Item(1).Range.Text = _ DateAdd("m", 12, CDate(ContentControl.Range.Text)) End If End If End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#7
|
|||
|
|||
![]()
I went into the document I sent you and clicked on the macros button. There was a Macros1 on the list. I clicked edit and inserted the code you provided and exited the Visual Basic. I then saved the document as a Macro Enabled Template. I then clicked on the template and chose the date on issue date, but the expiry date did not change.
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
newi1 | Word VBA | 3 | 04-22-2016 07:02 PM |
Autofill dates - how can I get the same date and consecutive dates? | Exhale | Excel | 3 | 04-05-2016 03:11 AM |
![]() |
lenoble22 | Word | 1 | 01-16-2014 12:20 PM |
How to change dates automatically | PaperBuster | Word | 5 | 09-24-2012 09:31 PM |
How to change number format of dates | ketanco | Project | 1 | 09-11-2012 02:34 PM |