Consulting

Results 1 to 5 of 5

Thread: Solved: Userform Calendar Control

  1. #1

    Solved: Userform Calendar Control

    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

  2. #2
    VBAX Mentor anandbohra's Avatar
    Joined
    May 2007
    Location
    Mumbai
    Posts
    313
    Location
    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.
    Always Mark your Thread as Solved the moment u got acceptable reply (located under Thread tools)
    Practice this & save time of others in thinking for unsolved thread

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Chnage the day labels and this procedure

    [vba]

    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
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  4. #4
    VBAX Mentor anandbohra's Avatar
    Joined
    May 2007
    Location
    Mumbai
    Posts
    313
    Location
    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
    Always Mark your Thread as Solved the moment u got acceptable reply (located under Thread tools)
    Practice this & save time of others in thinking for unsolved thread

  5. #5
    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.

Posting Permissions

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