|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
How do I get auto-updated "number of days since specified date" on MS word?
How do I get auto-updated "number of days since specified date" on MS word? In other words, I'd like to have this cell in my table autoupdate the interval of days between the date I specified and today's date. I know that there are several ways to do this. For example "fx=datedif(A1,today(),"d")" would work on Excel, but I am trying to find an alternative way.
MS visual basic? Found this online but don't know how to use it. Sub dateFunctions4() Debug.Print "The day part is: " & DatePart("d", Now) End Sub Macro's? Field codes? Help! Thanks. |
#2
|
||||
|
||||
Hi Terry,
It can be done with either macros of field coding. Which would you prefer? If it's field coding, you'd simply insert the field where you want the output to appear. If it's macros, you need to be able to tell Word where to insert/update the date. Does the 'specified date' need updating and, if so, is that to be done via, say, a FILLIN field, a bookmarked range, or a macro's inputbox?
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
||||
|
||||
I see you've cross-posted this at: http://answers.microsoft.com/en-us/o...c-68b599b31bf5
where you've already been pointed to a tutorial I wrote on the use of field coding for this. That may or may not meet your needs - which is why I asked for further info before pointing you in that direction. For cross-posting etiquette, please see: http://www.excelguru.ca/node/7
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#4
|
|||
|
|||
Hi macropod,
Thanks for the response! Let me give you a better idea of what I'm trying to do. This is for a surgery patient list on MS Word. We want to be able to enter an operation date in one cell of a table and then have the number of days since that date (post-operative day # or POD#) in another cell. So to answer your question, the specified date would not be changed. If I used field codes, then I'd have to make each operation date for each patient a bookmark and refer to it in the code for the POD#? I'd like to make this more user-friendly for other medical students like myself. Would a macro require less work? Thanks again! |
#5
|
|||
|
|||
I am very sorry, I rarely ever post on forums or boards. I wasn't expecting a response any time soon and thought that maybe posting on more than 1 would give me a better chance of getting one. Thanks for the etiquette link though.
I read the relevant portion of your tutorial (very well-written, btw). Is there a way to make it more user-friendly for other people to enter specified dates? |
#6
|
||||
|
||||
Hi Terry,
In that case, you'll need a macro-based solution. See attached. There's a 'Document Open' macro in it that automatically updates the first table in the document, which is assumed to have four coulms: • Patient name • Operation date • Post-Op days elapsed • Discharge date If you input a date in column 2 (Operation date) column 3 (Post-Op days elapsed) will be updated next time you open the document. Inputting a date in column 4 (Discharge date) will stop column 3's value updating beyond that date. Changing column 4's value will cause the column 3's value to be re-assessed.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#7
|
|||
|
|||
I really can't thank you enough!
We actually don't need a discharge date column, although that was a very nice gesture. Our other columns are "procedure, antibiotics and to-do", but I think I can add that myself. I attached a snipping of it to this post. How do I rid of the discharge date column? I think I'm going to read up on Visual Basic coding this weekend. It would be extremely helpful if you would explain how your macro works. I'm sure my resident will ask me to explain how he could incorporate this at the different hospitals he's going to be working at. Thanks again! You're awesome. |
#8
|
||||
|
||||
Hi Terry,
If you don't have a discharge date column or something equivalent, every count in the Post-Op days elapsed column will keep updating forever! So how's it supposed to know when to stop updating the count?
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#9
|
|||
|
|||
Oh, I forgot to mention that these aren't permanent records. It's a list for us to keep track of our patients currently in the hospital. We delete the patient's row once they are discharged.
|
#10
|
||||
|
||||
Hi Terry,
That makes a big difference! Try the attached - I'll let you take care of the formatting.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#11
|
|||
|
|||
Thank you so much! *thumbs up*
|
#12
|
|||
|
|||
This is great. Can you explain how it works so I can use it in other report formats that I have? i've downloaded the file you provided with the table but it doesn appear to have any fields or macros. Thanks!
Last edited by Subi84; 01-07-2016 at 08:10 AM. Reason: clarify question... |
#13
|
|||
|
|||
The tutorial explains how these work. Pay special attention to the first part on the construction and use of fields. The tutorial is full of sample fields.
|
#14
|
|||
|
|||
Yeah...thanks Charles but I already tried that. I may as well be reading hieroglyphs....
|
#15
|
||||
|
||||
The documents do indeed contain macros. They're Document_Open macros that you can't see via Alt-F8; instead you can access them via Word's VB Editor, which you can open via Alt-F11.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Wierd symbols inplace of "space", "indentation" etc | aka.bhagvanji | Word | 5 | 02-16-2012 11:50 AM |
Is there a way to make the cross-refernce format to be "Only lable and number"? | Jamal NUMAN | Word | 1 | 04-10-2011 03:31 PM |
Creating an Auto-Calc'd Date? Today+7 Days? | SoCalTelephone | Word | 0 | 10-06-2010 10:27 AM |
in WORD, how do i type a 9-digit phone number "xxxxxxxxx" and have it automatically.. | jay8962 | Word | 0 | 04-08-2010 11:08 AM |
"Microsoft Excel Application" missing in the "Component Services" on win08 | sword.fish | Excel | 0 | 02-26-2010 02:09 PM |