Page 1 of 3 123 LastLast
Results 1 to 15 of 33
  1. #1
    2 Star Lounger
    Join Date
    Jan 2004
    Location
    Kingwood, Texas, USA
    Posts
    112
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Changing dates in a document (2003)

    I publish a weekly newsletter that has a date of publication at the first of the newsletter. I have other sections in the newsletter that have different
    dates that are respectively either 4 or 7 days later than the publication. I would like to only have to change the 'master' date and have the rest change to reflect it is one week later rather than manually changing these (which I forget to do too often).

    Is there a way to do this in word without a macro? If not, is there a way with vba code?

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Changing dates in a document (2003)

    You can do it with fields. Have a look at the star post by <!profile=macropod>macropod<!/profile> which should give you the clues on how to do this

    Post 249902
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. #3
    2 Star Lounger
    Join Date
    Jan 2004
    Location
    Kingwood, Texas, USA
    Posts
    112
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Changing dates in a document (2003)

    Thanks. That was good stuff. Unfortunately either I don't understand some of the subtleties or it doesn't quite have what I am after. Here is what I want to do:

    Date 1 <== I change this every week. When I do Dates 2 & 3 update automatically
    Date 2 = Date 1+4 days
    Date 3 = Date 1+7 days

    I tried to simply install the field codes for calculating a stepped date, but had problems when trying to get it to do what I wanted. Also, I always have to remember to update fields so it is just as easy for me to forget that as to forget changing the 2 dates. <g> :-(

    In any event, on changing the stepped date code I tried to change the line suggested to reflect the next Wednesday and Sunday after the date in Date 1. I could do the Wed. without any problem. However, changing the Sunday date worked fine until I changed my computer calendar date to reflect next Sunday or any days following. Suddenly the date produced jumped to August! Obviously I missed something in what I was doing.

  4. #4
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Changing dates in a document (2003)

    I can understand where you are coming from as Macropod's fields are so ingenious that it is much easier for someone like me to do this with VBA code. The actual solution will depend on your answers to the following questions...

    Is Date1 today's date or something that you type in?
    Is Date2 meant to be Date1 + 4 days or the first wednesday after Date1?
    Is Date3 meant to be Date1 + 7 days or the first Sunday after Date1?

    If you don't want to update the fields with a Ctrl-A, F9 then a macro might be the way to go.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  5. #5
    2 Star Lounger
    Join Date
    Jan 2004
    Location
    Kingwood, Texas, USA
    Posts
    112
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Changing dates in a document (2003)

    Thanks for the asking. Re: questions

    Is Date1 today's date or something that you type in? ==> I want to type in this date
    Is Date2 meant to be Date1 + 4 days or the first wednesday after Date1? ==> I can't count; I actually want it to be date1+3. Date 1 is always a Sunday so I want date 2 to be the following Wednesday
    Is Date3 meant to be Date1 + 7 days or the first Sunday after Date1? ==> As mentioned above, date1+7 but again, that is one and the same as Sunday simply because Date1 is always a Sunday.

    I'm of the opinion that a macro is likely the way I should go but I'm open.

  6. #6
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Changing dates in a document (2003)

    The following macro will prompt you for a date and then return the three requested values formatted consistently. The values could be easily used in your document at bookmarks if you have created them and modified the code accordingly. You will find samples of how to do that in this lounge.
    <pre>Sub GimmeADate()
    Dim aDate1 As Date, aDate2 As Date, aDate3 As Date
    aDate1 = InputBox("Please type in the date (Sundays only)", "Start Date")
    aDate2 = aDate1 + 3
    aDate3 = aDate1 + 7
    Debug.Print Format(aDate1, "dddd, mmm d yyyy")
    Debug.Print "Three days later: " & Format(aDate2, "dddd, mmm d yyyy")
    Debug.Print "One week later: " & Format(aDate3, "dddd, mmm d yyyy")
    MsgBox "And the dates are..." & vbCr & Format(aDate1, "dddd, mmm d yyyy") & _
    vbCr & Format(aDate2, "dddd, mmm d yyyy") & _
    vbCr & Format(aDate3, "dddd, mmm d yyyy")
    End Sub</pre>

    Andrew Lockton, Chrysalis Design, Melbourne Australia

  7. #7
    Star Lounger
    Join Date
    May 2002
    Location
    Brisbane, Queensland, Australia
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Changing dates in a document (2003)

    As I am terrible at VBA, I've attached a document with a solution using date fields taken from macropods date calculation document.

    It uses an ASK field to prompt the user for date 1 & than calculates date 2 & 3 from that. I've highlighted red the bookmark fields where the delays are set.

    I normally put my ASK & SET fields at the top of my document and the date calculation where required.
    To update highlight the entire document & press F9. You will be prompted for start date. This will occur automatically if the document is being generated as part of a mailmerge, in which case you might only want to ASK once.
    Attached Files Attached Files

  8. #8
    2 Star Lounger
    Join Date
    Jan 2004
    Location
    Kingwood, Texas, USA
    Posts
    112
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Changing dates in a document (2003)

    Andrew,

    Thanks a bunch. I will go 'play' with the document and see if I can get the calc dates into my doc at the right time/place.

  9. #9
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Changing dates in a document (2003)

    Mathew's sample file does the job for you without having to rework the code to cater for the bookmarks. Give that one a go if you are in a hurry.

    When you open the file if you are not prompted for the date automatically, select all and press F9 to get under way.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  10. #10
    2 Star Lounger
    Join Date
    Jan 2004
    Location
    Kingwood, Texas, USA
    Posts
    112
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Changing dates in a document (2003)

    Thanks. Matthew. This appeared to work at first. Maybe I did something wrong (only using your document w/o any coding changes yet). If I enter 25/04/2004 as the date I get the following:

    Date 1 is Sunday, 25 April 2004
    Date 2 is Wednesday, 28 April 2004

    Date 3 is Thursday, 5 February 2004

    Date 1 and 2 are fine. But Date 3 blows up. This is similar, but not exactly what I ran into with the macropods date material myself. I never could figure this one out previously nor yet! :-(

    FWIW, if I enter any date later than the current date (like 11/04/2004) all of them blow up. But then this is really moot since I won't be entering dates later than the current date.

  11. #11
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Changing dates in a document (2003)

    Hi Colonel:
    You're not alone. I haven't figured out how to change it yet, but I get the same results as you. The reason is that the formulas are confusing the format Day/Month/Year with Month/Day/Year. My defaults are set for the US--Month/Day/Year. When I enter a dd (day) at the beginning of the ASK field that is 12 or less, the field treats it as a month. The two delays then become 3 months & 7 months instead of 3 days & 7 days.

    Later:
    I figured out the problem. The ASK field that is used doesn't allow for a date format...it asks for text. Therefore, the date format is the default one for the system. In order to change this, after the ASK field is used, you must use a SET field.

    This is the ASK field used:
    {ASK StartDate "What is the starting date, in dd/mm/yyyy format, please?" d {DATE @ "d/MM/yyyy"}}

    This is the SET field that must follow it:
    { SET StartDate { DATE @ "d/MM/yyyy" } }

    I don't have time right now to look at the Delay 1 & Delay 2 bookmarks, but the same problem exists there.

  12. #12
    2 Star Lounger
    Join Date
    Jan 2004
    Location
    Kingwood, Texas, USA
    Posts
    112
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Changing dates in a document (2003)

    Great. I don't know enough to understand the delay1/2 coding, but I did change formats and add (for some other sections that have dates that flow based upon the ASK date entered) so I am up to delay9 at this point.

    I also have changed the delay2-9 formats to be "mmmm d" and the delay1 to be "mmmm d, yyyy". I also changed the format line in the ASK to be:
    {ASK StartDate "What is the starting date, in dd/mm/yyyy format, please?" d {DATE @ "MM/d/yyyy"}}

    I don't know if this is all internally consistent, but the result is what I need except for this problem when we get to an end of the month date for ask, like Apr. 25, 2004. The way things are right now when ask fires I get the box with the following date in it: 04/13/2004. If I change this to 04/18/2004 then I get the following:
    April 18, 2004
    April 21
    April 28

    Then for my new bookmarks I get sequential dates for a week:
    April 19
    April 20
    April 21
    April 22
    April 23
    April 24
    April 25

    which is what I want. If only.... when ASK date entry is 4/25/2004 then I get:
    April 25, 2004
    April 28
    February 5

    Then for my new bookmarks I get sequential dates for a week:
    April 26
    April 27
    April 28
    April 29
    April 30
    January 5
    February 5

    Of course, you could have probably predicted this based upon what you wrote but for this poor non-programmer... I'm still stuck.

    Thanks for the help thus far.

  13. #13
    Star Lounger
    Join Date
    May 2002
    Location
    Brisbane, Queensland, Australia
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Changing dates in a document (2003)

    I've never had a problem with the date fields developed by macropod, maybe because we are using the same date format. dd/mm/yyyy

    I have not had any probems with the 25 April 2004 or any other forward date. I had always thought that macropods fields extracted the day, month year and thus if the input is in the correct format, then it should there shouldn't be a problem.

    I will have a play with my date format & see if I can replicate your problem. Could you post your revised document?

  14. #14
    2 Star Lounger
    Join Date
    Jan 2004
    Location
    Kingwood, Texas, USA
    Posts
    112
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Changing dates in a document (2003)

    Matthew,

    I've attached a zipped version of your original doc that I altered as described in my note. Look forward to your comments.

    Thanks.
    Attached Files Attached Files

  15. #15
    Star Lounger
    Join Date
    May 2002
    Location
    Brisbane, Queensland, Australia
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Changing dates in a document (2003)

    Unfortunately I can replicate your problem when WinXP's date format is mm/dd/yyy. However the problem does not appear when it is set at dd/mm/yyyy.

    My unstanding of macropod's date fields are limited to playing around the edges, much like what you have done. I've sent macropod a message asking him to look at your problem.

    Alternatively you could move Downunder. <img src=/S/aussie.gif border=0 alt=aussie width=21 height=22>

Page 1 of 3 123 LastLast

Posting Permissions

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