Add days to a date in Word 2010 form.
Solved
romanza
Posted messages
263
Status
Member
-
m@rina Posted messages 27590 Registration date Status Moderator Last intervention -
m@rina Posted messages 27590 Registration date Status Moderator Last intervention -
Hello,
I created a date field "A" in a Word 2010 form.
In this field, I need to enter a date.
I created another DATE field "B" which should calculate the date of field "A" + 37 days.
What should I write as an expression in field "B"?
Thank you for your help
Configuration: Windows 7 / Internet Explorer 7.0
I created a date field "A" in a Word 2010 form.
In this field, I need to enter a date.
I created another DATE field "B" which should calculate the date of field "A" + 37 days.
What should I write as an expression in field "B"?
Thank you for your help
Configuration: Windows 7 / Internet Explorer 7.0
7 answers
-
Good evening,
You create your two date fields.
Assuming they are named "Texte1" "Texte2", you enter the following macro:
Sub ladate()
Dim date1 As Date, date2 As Date
date1 = ActiveDocument.FormFields("Texte1").Result
date2 = date1 + 37
ActiveDocument.FormFields("Texte2").Result = date2
End Sub
You open the first date field, then under the "On exit" section, you select the macro ladate you previously entered.
You also check the "Calculate on exit" option.
You then open the second date field and uncheck the "Filling in enabled" option.
Now, you can protect the document. You enter any date in the first field and by pressing the Tab key, the second field will be automatically calculated with 37 days added.
m@rina
We are not clairvoyants: don’t forget to indicate the version of the software used and how you proceeded.