Private Sub CommandButton1_Click()
Dim CurSysTime As SYSTEMTIME
SendMessage dtHwnd, &H1001, 0&, CurSysTime
With CurSysTime
ComboBox1.AddItem Format(DateSerial(.wYear, .wMonth, .wDay), "Short Date")
ComboBox1.Value = ComboBox1.List(0)
ActiveCell = CDate(ComboBox1.Value)
End With
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
DestroyWindow dtHwnd
End Sub
Private Sub UserForm_Initialize()
Dim meHwnd As Long, h&
h = GetSystemMetrics(51)
meHwnd = FindWindow(vbNullString, Me.Caption)
dtHwnd = CreateWindowEx(0, "SysMonthCal32", vbNullString, _
&H50000000, 4, -h, 200, 200, meHwnd, 0&, 0&, ByVal 0&)
SetParent dtHwnd, meHwnd
ComboBox1.Top = (200 - h) * 3 / 4
CommandButton1.Top = (225 - h) * 4 / 6
CommandButton1.Height = 18
CommandButton1.Width = 48
CommandButton1.Caption = "OK"
CommandButton1.ZOrder 0
End Sub