Results 1 to 9 of 9
  1. #1
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Absolute date {field} (Word97SR2)

    How do I create a field calculation to show an absolute date?

    In particular, the progress report needs to show "nn days to scheduled launch", and I want the "nn" to be the difference between today's date and the date of September 1st 2001.

    When the progress report is printed and/or distributed, the field will automatically recalculate to show how little time we have left.

    In Excel I'd use a function like this "=DATE(2001,9,1)" and this "=Now()" and then subtract the two to find the difference. In Word's help files i can find no equivalent function.

    I'd like to gewt this working sometime in the next 56.69 days (grin!)

  2. #2
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Sun Prairie, Wisconsin, Wisconsin, USA
    Posts
    2,049
    Thanks
    124
    Thanked 119 Times in 116 Posts

    Re: Absolute date {field} (Word97SR2)

    Hi Chris,

    I don't think you'll be able to do this with a field alone. It should be pretty straightforward with VBA, though. Put a macro into the document open event that calculates the number of days and then either insert that number at a bookmark (being careful to not delete the bookmark in the process), or put it into a document property or variable and update a field in the document. If you are going to use it in a header or footer, it would have to be either a bookmark or a document property because a document variable field in the h/f will crash Word.
    Charles Kyle Kenyon
    Madison, Wisconsin

  3. #3
    4 Star Lounger
    Join Date
    Mar 2001
    Location
    Bismarck, ND, USA
    Posts
    451
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Absolute date {field} (Word97SR2)

    What does the Word document look like? Could a small one-cell Excel spreadsheet be linked to your Word document so that you could use the Excel function?
    egghead

  4. #4
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Absolute date {field} (Word97SR2)

    >It should be pretty straightforward with VBA, though

    It shall be done, oh mentor!


    Odd, though, I wold have thought that simple date conversions (y,m,d to date) would have been a basic requirement for some of thes epeople who do mail-merge and the like, especially for conditional merges.

    Being told that it can't be done frees me up to do what I wanted to do in the first place - write another procedure!

  5. #5
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Absolute date {field} (Word97SR2)

    >one-cell Excel spreadsheet be linked to your Word document

    Good one, but not in this case. I want to be able to email a document to a client and have a reminder pop up.

    Actually, ahem, you've got me thinking now.

    An Open Event a la Charles Kenyon but instead of just loading text into the document (blah blah blah ..), have the VBA code pop up a jack-in-the-box, very much in-your-face only so many days left.

  6. #6
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Sun Prairie, Wisconsin, Wisconsin, USA
    Posts
    2,049
    Thanks
    124
    Thanked 119 Times in 116 Posts

    Re: Absolute date {field} (Word97SR2)

    I suppose I overstated when I said it couldn't be done. I probably should have said that I wouldn't do it. What follows is the combination of fields that gives the date 14 days from today. Something similar would be required, accounting for leap years, etc.

    { QUOTE "{ SET Delay "14" }{ SET "DaysInMonth" { IF { CREATEDATE @ "MM" } <> 2 { = round(30.575*{ CREATEDATE @ "MM" },0)-ROUND(30.575*{ = { CREATEDATE @ "MM" } -1 },0) }{ IF { = MOD({ CREATEDATE @"yy" }, 4 ) } > 0 "28" "29" } } }{ SET "NextMonth" { IF { CREATEDATE @ "MM" } = 12 "1/97" "{ = { CREATEDATE @ "MM" } + 1 }/97 } }{ IF { = { REF Delay } + { CREATEDATE @ "dd" } } <= { DaysInMonth }{ CREATEDATE @ "MMMM { = { REF Delay} + { CREATEDATE @ "dd" } }, yyyy"}{ QUOTE { NextMonth @ "MMMM" } { = { REF Delay } + { CREATEDATE @ "dd" } - { DaysInMonth } }, { IF { } CREATEDATE @ "MM" } <> 12 { CREATEDATE @ "yyyy" }{ CREATEDATE @ "{ = 1 + { CREATEDATE @ "yyyy" } # "xxxx" }" } } } }" }

    (And those braces matched when I typed this, I swear it.")

    BTW, my host has provided another temporary site for me so as I write this FrontPage is chugging away trying to squeeze 50 MB or so through a 56K modem. 5 meg down, 45 to go.
    Charles Kyle Kenyon
    Madison, Wisconsin

  7. #7
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Absolute date {field} (Word97SR2)

    Don't EVER send me so many braces before I've had my first belt of the morning (grin!).


    In a word "ugh!".


    Here's the doo-dad:

    <pre>Private Sub Document_Open()
    Call CountDown
    End Sub
    Sub CountDown()
    Dim dat As Date
    dat = DateSerial(2001, 9, 1)
    MsgBox dat - Date & " days to " & Format(dat, "MMM dd, yyyy")
    End Sub
    </pre>


    I can imagine all sorts of enhancements, such as, overstepping the date creates a different message; various levels of panic displayed as the day grows closer, etc.

  8. #8
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Absolute date {field} (Word97SR2)

    What about:

    <pre>MsgBox DateDiff("D", Now, #9/1/2001#) & " days to go"
    </pre>

    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  9. #9
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Sun Prairie, Wisconsin, Wisconsin, USA
    Posts
    2,049
    Thanks
    124
    Thanked 119 Times in 116 Posts

    Re: Absolute date {field} (Word97SR2)

    That looks a lot cleaner! BTW, with those field codes, at least some of the spaces are mandatory! Not fun.
    Charles Kyle Kenyon
    Madison, Wisconsin

Posting Permissions

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