• Fields in a form

    • This topic has 8 replies, 2 voices, and was last updated 24 years ago.
    Author
    Topic
    #355626

    I know how to put a field in my Word2000 doc to automatically print todays date. Is there an easy way to show todays date plus 6 months or other predetermined period of time?

    In other words, the document “date” field would be today, but further on in my document I want to list an expiration date of 6 months from “Today’s date”.

    If this could be in number of days or number of months, that would be the most helpful

    Viewing 3 reply threads
    Author
    Replies
    • #524885

      Thanks for the help. Why does everything have to be so difficult? You should be able to do “Today +180”, but that would be too simple!

      Thanks again

      • #524889

        I went to the link supplied and copied the prevmonth macro and with editing can make it go ‘ahead’. But how can I tell it where to put it in my document. Right now it just dumps wherever my cursor is. Yes, I am new to VB!

    • #524940

      To get the date where you want it, you can set a bookmark at that point, called say “SixMonthsHence” and go there before inserting the date.

      The VBA code to go to the bookmark is
      Selection.GoTo What:= wdGoToBookmark Name:=”SixMonthsHence”

      Hope this helps

      Ian.

      • #524969

        Yes it does. No it doesn’t. I’m still learning VB, so I hope you understand my “greeness”. Here’s my code with your line copied in that doesn’t work:
        ————————————-
        Sub Add_6_Months()
        Dim mbefore As Date
        mbefore = Format(DateAdd(“m”, 6, Date), “dd mmmm yyyy”)
        Selection.InsertBefore mbefore
        wdGoToBookmark Name:=”Six_Months”
        —————————-
        The “mbefore” and the rest of this code came from the web site referenced in a response above. I honestly don’t understand the “Insert”, as I would think that would do the insert.

        I’ve moved the statement you gave me around, but still get a “compile error, invalid use of property” error.

        More help please!

        • #524999

          The following works for me. My apologies that I left a comma out of the line I sent before – I’m pretty new at this too!

          (You may want to format the date differently)

          Ian
          =================================

          Sub Add_6_Months()
          Selection.GoTo What:=wdGoToBookmark, Name:=”Six_Months”
          Selection.InsertAfter DateAdd(“m”, 6, Date)
          End Sub

          • #525019

            Cool! That works. I have three different date fields like that. Can I combine that into one macro?

            And can I make that macro run upon opening the form?

    • #525032

      Great resourses! Thanks. I got it working!
      The first link you gave me, in the upper section give specific instructions on “Two list boxes” I don’t see those I’m running Office Prof2000.

      I got it to work using the second section on AutoMacros

      Thanks again!

    • #525033

      Lawerence, thanks for your great stuff too! I’ll give it a rip!

    Viewing 3 reply threads
    Reply To: Fields in a form

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: