

'~~> Unload the form when the user presses Escape In the Class Module (Let's call it CalendarClass) paste this code Public WithEvents CommandButtonEvents As MSForms.CommandButton To incorporate this into your project, simply export the Userform, Module and the Class Module from the sample file and import it into your project. The sample file (added at the end of the post) has a Userform, Module and a Class Module. This is what the calendar looks like in Windows 10: This post is about how to create a calendar widget which is not dependant on any ocx or 32bit/64bit and can be freely distributed with your project. When I saw the Windows 10 calendar which popped up when I clicked on the date and time from the system tray, I could not help but wonder if we can replicate that in VBA. This calendar, using Userform and Worksheet, was suggested earlier and is incredibly basic. If you include them in your project and distribute them to your friends, neighbours, clients etc the application may or may not work depending on whether they have those ocx installed.Īnd hence it is highly advisable NOT to use them in your project

So what problem can I face if I include these in my applicaiton? The Monthview Control, Datetime Picker and the deprecated Calendar control look like below.

Having said that, the deprecated mscal.ocx may or may not work on Windows 10.ĭepending on your Windows and Office versions (32 bit or 64 bit), it can be really painful to register these ocxs. Similarly for mscal.ocx and mscomctl.ocx. To install the Montview Control and Datetime Picker, we need to set a reference to Microsoft MonthView Control 6.0 (SP4) which can only be accessed by elevated registration of mscomct2.ocx. These are VB6 controls and are not native to VBA environment. In VBA, three main kinds of date time controls can be used provided certain ocxs have been registered using administrator rights.
