Results 1 to 3 of 3
  1. #1
    5 Star Lounger Lou Sander's Avatar
    Join Date
    Jun 2002
    Location
    Pittsburgh, PA
    Posts
    855
    Thanks
    140
    Thanked 10 Times in 9 Posts

    Improving a Date Stamp macro that I got from the Lounge

    THIS THREAD describes two slick little Date Stamp macros that I use for keeping track of things for my physician. The code, created by macropod, appears in Post #6.

    The first one puts a specially-formatted Date Stamp into my Word 2010 document when I execute it. I typically do that at the start of a paragraph. The second macro goes through my document and inserts some text stating how many days ago each Date Stamp was created. I've put icons for them on my Quick Access Toolbar, so it's pretty easy to use them.

    I've used the pair for several months now, and they are very useful to me and to the doctor. I'd like to make the following improvements, but coding them is beyond my skill level:

    Once a Date Stamp is over 89 days old, I'd like the second macro to express the elapsed time in integral months, rather than days. I'm not fussy about precision here... if it has been anything between 90 days and 119 days, expressing it as "3 months" would be fine. If anybody wants a more precise indication of elapsed time, they can just look at the original Date Stamp and do the calculations.

    There's something else I'd like to do, too. Whenever the second macro is executed, I'd like to put an indication in the document as to the date it was executed. That would let people know the "ago" in "45 days ago", "8 months ago", etc.

    I haven't figured out where I want to put that information, or in what format. I just know it would be great to include it. I imagine I'd do something to set it up the first time the "days ago" macro is executed, then update it when that macro is used later.
    Last edited by Lou Sander; 2016-06-16 at 17:05.
    Lou Sander
    Pittsburgh, Pennsylvania
    USA

  2. #2
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts
    Change:
    .InsertAfter " (" & Int(Now - CDate(.Text)) & " days ago)"
    to:
    Code:
        If DateDiff("m", CDate(.Text), Now) > 2 Then
          .InsertAfter " (" & DateDiff("m", CDate(.Text), Now) & " months ago)"
        Else
          .InsertAfter " (" & Int(Now - CDate(.Text)) & " days ago)"
        End If
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  3. #3
    WS Lounge VIP
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    8,199
    Thanks
    48
    Thanked 986 Times in 916 Posts
    Would it be better to have the "days ago" value auto update when you view the document?

    cheers, Paul

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •