Microsoft Office Tutorials and References
In Depth Information
Using Calendar Control for Office Applications
End Sub¶
' * * * * *¶
Private Sub UserForm_Activate()¶
If Me.cmbMonth.ListIndex = -1 Then¶
Call SelectDate¶
End If¶
End Sub¶
' * * * * *¶
Private Sub UserForm_Initialize()¶
Me.Value = CLng(Date)¶
'Set default colors for objects¶
cVarDayBackColor = &HFFFFFF¶
cVarDayForeColor = &H80000012¶
cVarSelBackColor = &H8000000D¶
cVarSelForeColor = &HFFFFFF¶
cVarSelBackToday = &HFF&¶
cVarSelForeToday = &HFFFFFF¶
cVarDisForeColor = &H80000010¶
cVarBackColor = &HFFFFFF¶
cVarForeColor = &H80000012¶
Call SetDefaults¶
End Sub¶
' * * * * *¶
Public Property Let Value(ByVal vNewValue As Date)¶
'Set calendar value and¶
'assign related day, month and year variables¶
'by using current value of calendar¶
cvarValue = vNewValue¶
cVarCYear = Year(cvarValue)¶
cVarCMonth = Month(cvarValue)¶
cVarCDay = Day(cvarValue)¶
End Property¶
' * * * * *¶
Public Property Get Value() As Date¶
'Return form's Value property¶
Value = cvarValue¶
End Property¶
' * * * * *¶
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)¶
'variable declaration¶
Dim selcell As Object¶
If CloseMode = 0 Then Exit Sub¶
'Continue when error occurs¶
On Error Resume Next¶
'Different actions for Excel and Word¶
If Application.Name = "Microsoft Excel" Then¶
Set selcell = Selection¶
selcell.Cells(1, 1).Value = Me.Value¶
ElseIf Application.Name = "Microsoft Word" Then¶
Selection.typetext Me.Value¶
Cmb
Search JabSto ::




Custom Search