schmolio007
New Member
I recently created a customizable, VBA-based date picker, and thought it might be of use to someone else. I know there are already a lot of custom date pickers out there to overcome the difficulties of using Microsoft's MonthView control. But I wanted one that could be customized to match the look and feel of whatever project it is being used in. I was never able to find one that could do this without significant code re-write.
You can click here to download the custom date picker I came up with. Below are some screenshots of the form in action.
To use the date picker, simply import the CalendarForm.frm file into your VBA project. Each of the calendars above can be obtained with one single function call. The result just depends on the arguments you use (all of which are optional), so you can customize it as much or as little as you want.
For example, the most basic calendar on the left can be obtained by the following line of code:
That's all there is to it. From there, you just include whichever arguments you want to get the calendar you want. The function call below will generate the green calendar on the right:
Here is a small taste of some of the features it includes. All options are fully documented in the userform module itself:
You can click here to download the custom date picker I came up with. Below are some screenshots of the form in action.
To use the date picker, simply import the CalendarForm.frm file into your VBA project. Each of the calendars above can be obtained with one single function call. The result just depends on the arguments you use (all of which are optional), so you can customize it as much or as little as you want.
For example, the most basic calendar on the left can be obtained by the following line of code:
Code:
MyDateVariable = CalendarForm.GetDate
That's all there is to it. From there, you just include whichever arguments you want to get the calendar you want. The function call below will generate the green calendar on the right:
Code:
MyDateVariable = CalendarForm.GetDate( _
SelectedDate:=Date, _
DateFontSize:=11, _
TodayButton:=True, _
BackgroundColor:=RGB(242,248,238), _
HeaderColor:=RGB(84,130,53), _
HeaderFontColor:=RGB(255,255,255), _
SubHeaderColor:=RGB(226,239,218), _
SubHeaderFontColor:=RGB(55,86,35), _
DateColor:=RGB(242,248,238), _
DateFontColor:=RGB(55,86,35), _
SaturdayFontColor:=RGB(55,86,35), _
SundayFontColor:=RGB(55,86,35), _
TrailingMonthFontColor:=RGB(106,163,67), _
DateHoverColor:=RGB(198,224,180), _
DateSelectedColor:=RGB(169,208,142), _
TodayFontColor:=RGB(255,0,0), _
DateSpecialEffect:=fmSpecialEffectRaised)
Here is a small taste of some of the features it includes. All options are fully documented in the userform module itself:
- Ease of use. The userform is completely self-contained, and can be imported into any VBA project and used without much, if any additional coding.
- Simple, attractive design.
- Fully customizable functionality, size, and color scheme
- Limit user selection to a specific date range
- Choose any day for the first day of the week
- Include week numbers, and support for ISO standard
- Clicking the month or year label in the header reveals selectable comboboxes
- Dates change color when you mouse over them