Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Jan 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Macro for Word 2003

    Hi,
    I work for a travel agency and often have to produce itineraries.
    I would like to create a template where I can just enter the start date and the end date and would get a result like the one below:

    Saturday, December 24, 2011

    Sunday, December 25, 2011

    Monday, December 26, 2011

    Tuesday, December 27, 2011

    Wednesday, December 28, 2011

    Thursday, December 29, 2011

    Friday, December 30, 2011

    This would save me a lot of time and typing.

    Thanks

  2. #2
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    Hi Yohai,

    Welcome to the Lounge.

    To see how to do this and just about everything else you might want to do with dates in Word (without the need for macros), check out my Microsoft Word Date Calculation Tutorial, at:
    http://lounge.windowssecrets.com/ind...owtopic=249902
    In particular, look at the item titled 'Calculate a Date Sequence'. Do read the document's introductory material.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  3. #3
    New Lounger
    Join Date
    Jan 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Paul,
    Thanks for the quick reply!
    The 'Calculate a Date Sequence' is good if I want to start the sequence today but I need the ability to start at any date and end at any date.
    I'm also kind of a first timer with these kind of settings in Word, so I would appreciate an "idiots guide" to do this.

    Thanks

    Yohai

  4. #4
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    Hi Yohai,

    Replace the first field with one coded as:
    {QUOTE{ASK StartDate "Start date"}{StartDate \@ "D MMMM YYYY"}}
    Note: The field brace pairs (ie '{ }') for the above example are created via Ctrl-F9 - you can't simply type them or copy & paste them from this message.

    With the second field, select it and press Shift-F9 to expose the field code. Then replace the four 'DATE' strings with 'StartDate', as indicated, so that you end up with:
    {QUOTE
    {SET Delay 1}
    {SET a{=INT((14-{StartDate \@ M})/12)}}
    {SET b{={StartDate \@ yyyy}+4800-a}}
    {SET c{={StartDate \@ M}+12*a-3}}
    {SET d{StartDate \@ d}}
    {SET jd{=d+INT((153*c+2)/5)+365*b+INT(b/4)-INT(b/100)+INT(b/400)-32045+Delay}}
    {SET e{=INT((4*(jd+32044)+3)/146097)}}
    {SET f{=jd+32044-INT(146097*e/4)}}
    {SET g{=INT((4*f+3)/1461)}}
    {SET h{=f-INT(1461*g/4)}}
    {SET i{=INT((5*h+2)/153)}}
    {SET dd{=h-INT((153*i+2)/5)+1}}
    {SET mm{=i+3-12*INT(i/10)}}
    {SET yy{=100*e+g-4800+INT(i/10)}}
    "{dd}-{mm}-{yy}" \@ "dddd, d MMMM yyyy"}
    Cheers,

    Paul Edstein
    [MS MVP - Word]

Tags for this Thread

Posting Permissions

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