Microsoft Office Tutorials and References
In Depth Information
Using Calendar Control for Office Applications
Using Calendar Control for Office Applications
By Suat Ozgur
This sample code shows a custom calendar that would make it easy for a user
to select a date from it.
Example file:
O015.doc and
O015.xls
Scenario: When using Excel or Word it is handy to have a
calendar you can use to place a date in the worksheet or
document you are working in.
To use this control in applications, transfer the clsCalendar, frmCalendar, and
basCalendar objects from the sample documents into the worksheet or
document in which it will be used.
Place the following code in the basCalendar module. This is a Standard module
that has been renamed basCalendar using the name box in the properties
window (bottom left) of the Visual Basic Editor (VBE). This can be imported
and exported for use in other projects.
Option Explicit¶
' * * * * *¶
Public Sub ShowForm()¶
With frmCalendar¶
.Show¶
End With¶
End Sub¶
Insert the following code in the UserForm module of UserForm frmCalendar.
Option Explicit¶
'forces variable declaration¶
Private cvarValue As Date¶
Private cVarCDay As Byte 'Day¶
Private cVarCMonth As Byte 'Month¶
Private cVarCYear As Integer 'Year¶
Private cVarDayBackColor As Long 'Day backcolor¶
Private cVarDayForeColor As Long 'Day forecolor¶
Private cVarSelBackColor As Long 'Selected backcolor¶
Private cVarSelForeColor As Long 'Selected forecolor¶
Private cVarSelBackToday As Long 'Today backcolor¶
Private cVarSelForeToday As Long 'Today forecolor¶
Private cVarDisForeColor As Long 'Disabled forecolor¶
Private cVarBackColor As Long 'Calendar backcolor¶
Private cVarForeColor As Long 'Calendar forecolor¶
Cmb
 
Search JabSto ::




Custom Search