2007 vs 2010 calendar control issue

dinotom

Active Member
Joined
Aug 2, 2009
Messages
357
I have many users for this program who are now moving to excel 2010. Since in Excel 2010 the calendar control uses the vba syntax of ufCalendar.Calendar1, where as in Excel 2007 it is ufCalendar.Calendar, I would need to test for what version is running. so this code should do the trick. (it's an event handler, ufCalendar is the name of the calendar form)

Code:
Private Sub tbStartDate_Enter()
   If Application.Version = "14.0" Then
    Load ufCalendar
    ufCalendar.Show
     Me.tbStartDate.Value = ufCalendar.Calendar1.Value
  Else
    Load ufCalendar
    ufCalendar.Show
    Me.tbStartDate.Value = ufCalendar.Calendar.Value
  End If
End Sub

But lo and behold I get a compile error because right now I'm using 2010 and it doesn't recognize the ufCalendar.Calendar. I tried andding On Error Resume Next everywhere in this routine but it still won't work. I need a solution, help!
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Thomas

Calendar1 is the name of the calendar on ufCalendar.

I can't see why you would use Calendar unless the name has changed.
 
Upvote 0
Hi Thomas,

...Since in Excel 2010 the calendar control uses the vba syntax of ufCalendar.Calendar1, where as in Excel 2007 it is ufCalendar.Calendar

I am at home, so in rusty/dusty Excel 2000 and no ability to test 2010. So... hopefully I'm not way off here, but 'Calendar1' should just be the default object name given to the calendar when it was created in design-time, (Actually, even if created in run-time I believe) like Userform1 for the first form created in a project.

Again, hoping not to waste your time, but might have you just dropped the '1' when you built the project originally?

The problem I have run into with the Cal control is that when I created it in 2000 and then ran the wb in 2003, all the buttons or text (or both, I forget) all got jacked up.

...I would need to test for what version is running. so this code should do the trick. (it's an event handler, ufCalendar is the name of the calendar form)

Disregarding the calendar specifically, and unfortunately intested, but assuming compile on demand is ticked, I think you could split what is to happen (Ver dependant) into different modules.

Code:
Private Sub tbStartDate_Enter()
   If Application.Version = "14.0" Then
    Module1.SomeProcedure
  Else
    Module2.SomeOtherProcedure
  End If
End Sub

Sorry for what is too much presuming, but hopefully a quick/easy test on your end.

Mark
 
Last edited:
Upvote 0
For me a calendar control is always named by default to Calendar1. Code like this works for me in Excel 2003-2010 with no modification

Code:
Private Sub CommandButton1_Click()
Unload UserForm1
End Sub

Private Sub Calendar1_Click()
ActiveCell.Value = Calendar1.Value
Unload Me
End Sub

Private Sub Calendar1_Click()
lblDate.Caption = Calendar1.Value
End Sub

Private Sub UserForm_Initialize()
Calendar1.Value = Date
With Me
    .Top = ActiveCell.Top
    .Left = ActiveCell.Left + ActiveCell.Width
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,544
Messages
6,179,430
Members
452,915
Latest member
hannnahheileen

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top