PDA

View Full Version : Solved: Userform Calendar Control



perhol
01-14-2008, 06:55 PM
I use the native calendar contol from Excel in a couple of workbooks, and i have to make sure that the right version of the calendar control is installed on every computer that uses these workbooks, or the workbooks will not function as i want them to.

Now i have found lucas' Userform Calendar Control, and it is nearly perfect.

Only i live in Denmark, and in Denmark the week starts by monday.

Can anyone change lucas' calendar contol to start the week on mondays?

The code is quite long, so i just post a link to the kbase:

http://vbaexpress.com/kb/getarticle.php?kb_id=543

anandbohra
01-15-2008, 02:29 AM
why dont u use simple calender control object over a form & show it as & when needed with Shortcut key or command button or whatever u feel comfirtable as it comes with build in customization for start date, start day etc etc.

Bob Phillips
01-15-2008, 02:29 AM
Chnage the day labels and this procedure



Private Sub Build_Calendar()
'the routine that actually builds the calendar each time
If CreateCal = True Then
CalendarFrm.Caption = " " & CB_Mth.Value & " " & CB_Yr.Value
'sets the focus for the todays date button
CommandButton1.SetFocus
For i = 1 To 42
If i < Weekday((CB_Mth.Value) & "/1/" & (CB_Yr.Value)) Then
Controls("D" & (i)).Caption = Format(DateAdd("d", (i - Weekday((CB_Mth.Value) & "/1/" & (CB_Yr.Value), 2)), _
((CB_Mth.Value) & "/1/" & (CB_Yr.Value))), "d")
Controls("D" & (i)).ControlTipText = Format(DateAdd("d", (i - Weekday((CB_Mth.Value) & "/1/" & (CB_Yr.Value), 2)), _
((CB_Mth.Value) & "/1/" & (CB_Yr.Value))), "m/d/yy")
ElseIf i >= Weekday((CB_Mth.Value) & "/1/" & (CB_Yr.Value)) Then
Controls("D" & (i)).Caption = Format(DateAdd("d", (i - Weekday((CB_Mth.Value) _
& "/1/" & (CB_Yr.Value), 2)), ((CB_Mth.Value) & "/1/" & (CB_Yr.Value))), "d")
Controls("D" & (i)).ControlTipText = Format(DateAdd("d", (i - Weekday((CB_Mth.Value) & "/1/" & (CB_Yr.Value), 2)), _
((CB_Mth.Value) & "/1/" & (CB_Yr.Value))), "m/d/yy")
End If
If Format(DateAdd("d", (i - Weekday((CB_Mth.Value) & "/1/" & (CB_Yr.Value), 2)), _
((CB_Mth.Value) & "/1/" & (CB_Yr.Value))), "mmmm") = ((CB_Mth.Value)) Then
If Controls("D" & (i)).BackColor <> &H80000016 Then Controls("D" & (i)).BackColor = &H80000018 '&H80000010
Controls("D" & (i)).Font.Bold = True
If Format(DateAdd("d", (i - Weekday((CB_Mth.Value) & "/1/" & (CB_Yr.Value), 2)), _
((CB_Mth.Value) & "/1/" & (CB_Yr.Value))), "m/d/yy") = Format(ThisDay, "m/d/yy") Then Controls("D" & (i)).SetFocus
Else
If Controls("D" & (i)).BackColor <> &H80000016 Then Controls("D" & (i)).BackColor = &H8000000F
Controls("D" & (i)).Font.Bold = False
End If
Next
End If
End Sub

anandbohra
01-15-2008, 02:37 AM
PL find attached herewith the form file (taken form internet or somother source dont know exactly but NOT MY CODE)

zip file contain Calender.frm file import it in your VBA Project

perhol
01-15-2008, 03:11 AM
xld
Thankyou, it works. I already did change the day labels.

anandbohra
I already use the native calendar contol from Excel, and therefor have a calendar form. But when using the native calendar contol from Excel with a homebuild form, you have to make sure that mscal.ocx is installed properly.
You have to do this on every computer you want to use the calendar control on.
Seemes mutch easyer to just use a in-workbook calendar control.