• Set Calendar Control to Current Date (VBA Word 97)

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Set Calendar Control to Current Date (VBA Word 97)

    Author
    Topic
    #359287

    My user form has a Calendar control called “CalendarControl”. I want the current date to get focus when the form is loaded. I know this sounds like a simple thing but I can’t for the life of me get it to work. I thought I should just use:

    CalendarControl.Value = Date

    The value under properties keeps reverting back to the date I wrote the code…any help for this novice would be appreciated since it seems EVERYTHING I find on the internet has to do with Access, not Word and although similar, what works for Access doesn’t necessarily work for Word.

    Viewing 0 reply threads
    Author
    Replies
    • #538125

      Try dropping the Value property and just set the calendar control equal to Date. Since the control isn’t an Access control at all, this should work in Word as well.

      • #538126

        Thanks Charlotte — but that doesn’t work for me either…

        • #538154

          Joanne,

          Try “Now” rather than “Date”(?)

          Gary

          • #538155

            No luck… but thank you.

            • #538162

              Where are you putting that code? It should be in the form initilize event routine.

            • #538180

              Thanks to all who have made suggestions. I figured out the error of my ways…. and am absolutely mortified to admit that I had neglected to include the form name prior to the control…

              Hence:

              frmCalendar.CalendarControl = Date

              Must have been a rougher weekend than I thought. dizzy

            • #538188

              Using Option Explicit will find those kind of problems quickly.

            • #538199

              Thank you Legare. I shall use that statement unfailingly in the future blush

    Viewing 0 reply threads
    Reply To: Set Calendar Control to Current Date (VBA Word 97)

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

    Your information: