Please help me display the number of days between two dates from Date Picker Content Control in a Microsoft Word 2013 Document.

Please help me display the number of days between two dates from Date Picker Content Control in a Microsoft Word 2013 Document.
Arnel MamarilAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

EirmanChief Operations ManagerCommented:
You can do some date calculations with fields in Word, but unlike excel/access it's awkward and complicated.
http://wordribbon.tips.net/T008660_Calculating_Dates_with_Fields.html
http://www.addbalance.com/word/datefields2.htm

I use this site for date calculations.
0
Ryan ChongCommented:
do you have a sample to upload to show how's your document would look like and how the output you want to be displayed?

are you ok if macro is involved in the document?
0
Arnel MamarilAuthor Commented:
Hello Ryan,
Thank you for your message.  Attached herewith is the sample document.  I'm ok involving a macro in the document.
Days-Calculation.docx
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

Ryan ChongCommented:
you can try this...

Sub test()
    Dim d As Integer
    Dim d1 As Date
    Dim d2 As Date
    d1 = ActiveDocument.ContentControls(1).Range
    d2 = ActiveDocument.ContentControls(2).Range
    d = DateDiff("d", d1, d2)
    ActiveDocument.ContentControls(3).Range = d
End Sub

Open in new window


I try to catch the change events for the datetime picker so that the value of "No of Days" could be updated automatically, just wondering if that's possible. I'm still trying that...
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ryan ChongCommented:
the closest I can get is to call the Document_ContentControlOnExit event:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
    Call test
End Sub

Open in new window

or you may referring and do some research on this article and see if we really can improve from there

Content Control Custom Events
http://maxey.mvps.org/word_tip_pages/Old_Tip_Pages/ContentControl_OnChange_Event.htm
0
Arnel MamarilAuthor Commented:
Thank you very much Ryan, it worked pretty well :)
Much appreciated
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Word

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.