PC Review


Reply
Thread Tools Rate Thread

2nd question - Calendar Control 8.0

 
 
Robert Crandal
Guest
Posts: n/a
 
      21st Nov 2009
I found some code on the Internet that describes how to add
the "Calendar Control 8.0" onto your Excel spreadsheet.
It explains to first create a Userform and then to place the
control on top of the Userform.

The website then explains to paste the following code into your
Userform module:

Private Sub Calendar1_Click()

ActiveCell = Calendar1.Value
ActiveCell.NumberFormat="mm/dd/yy"

End Sub

Private Sub UserForm_Activate()

Me.Calendar1.Value = Date

End Sub

I understand the code for "Calendar1_Click()", but can someone
help me understand the code for "UserForm_Activate()"???
I'm not sure why this code is necessary or what it does?? I am
able to delete the code in "UserForm_Activate()" and the calendar
control still works fine without it, so I just want to know what it does.

Thank you!


 
Reply With Quote
 
 
 
 
JLatham
Guest
Posts: n/a
 
      21st Nov 2009
The _Activate event fires when the form is activated. That can be upon
initial opening of the form or when you have it open, click on some other
object, such as a worksheet, and then back to the form. So this is a reset
mechanism to set the calendar date back to the system date if you've been
twiddling around on another form, worksheet, or other application. And
you're right, it will work just fine without that code, you just lose that
'reset' function.

Actually, what I'd probably do is to move that line of code into the
UserForm_Initialize()
routine. That would set the date when the form is loaded, leave it alone
while it is in use, and if you use an
Unload Me
statement anywhere, reset it to the current system date the next time you
open the form.

"Robert Crandal" wrote:

> I found some code on the Internet that describes how to add
> the "Calendar Control 8.0" onto your Excel spreadsheet.
> It explains to first create a Userform and then to place the
> control on top of the Userform.
>
> The website then explains to paste the following code into your
> Userform module:
>
> Private Sub Calendar1_Click()
>
> ActiveCell = Calendar1.Value
> ActiveCell.NumberFormat="mm/dd/yy"
>
> End Sub
>
> Private Sub UserForm_Activate()
>
> Me.Calendar1.Value = Date
>
> End Sub
>
> I understand the code for "Calendar1_Click()", but can someone
> help me understand the code for "UserForm_Activate()"???
> I'm not sure why this code is necessary or what it does?? I am
> able to delete the code in "UserForm_Activate()" and the calendar
> control still works fine without it, so I just want to know what it does.
>
> Thank you!
>
>
> .
>

 
Reply With Quote
 
Mike Fogleman
Guest
Posts: n/a
 
      22nd Nov 2009
It is not necessary to put a Calendar on a UseerForm. You can put it right
on the spreadsheet if you want.

Mike F
"Robert Crandal" <(E-Mail Removed)> wrote in message
news:0iYNm.17381$(E-Mail Removed)...
>I found some code on the Internet that describes how to add
> the "Calendar Control 8.0" onto your Excel spreadsheet.
> It explains to first create a Userform and then to place the
> control on top of the Userform.
>
> The website then explains to paste the following code into your
> Userform module:
>
> Private Sub Calendar1_Click()
>
> ActiveCell = Calendar1.Value
> ActiveCell.NumberFormat="mm/dd/yy"
>
> End Sub
>
> Private Sub UserForm_Activate()
>
> Me.Calendar1.Value = Date
>
> End Sub
>
> I understand the code for "Calendar1_Click()", but can someone
> help me understand the code for "UserForm_Activate()"???
> I'm not sure why this code is necessary or what it does?? I am
> able to delete the code in "UserForm_Activate()" and the calendar
> control still works fine without it, so I just want to know what it does.
>
> Thank you!
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calendar Control Question JamesJ Microsoft Access Forms 5 11th May 2008 08:44 PM
question on .net calendar control =?Utf-8?B?UGF1bA==?= Microsoft ASP .NET 3 27th Jan 2006 09:36 PM
Calendar Control Question Manoj Paramu Das Microsoft Dot NET 2 28th Jan 2005 03:56 PM
Calendar Control question =?Utf-8?B?RXZhbg==?= Microsoft Access 2 8th Aug 2004 07:54 PM
Calendar Control Question Randy Fritz Microsoft Access Form Coding 1 9th Mar 2004 02:30 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:07 PM.