T
TomS
Hello,
I am preparing small application in VBA for Word (Office 2000/XP) and need
a calendar to pick a date to text field. I tried to use MonthView control,
but it occured that it is not available on some machines. Installing this
ActiveX control on all machines is a big problem - application must work
without installing any additional software.
So I try to make it so, that this control will be shown only when it is
available. I have loaded it dynamically and check if it goes ok. But I
have problem: getting events from control doen't work.
Example code:
Private ctlCalendar As Control
Private Sub UserForm_Activate()
On Error Resume Next
Set ctlCalendar = Me.Controls.Add("MSComCtl2.MonthView.2",
"ctlCalendar", true)
end sub
Private Sub ctlCalendar_DateClick(ByVal DateClicked As Date)
txtDate = FormatDateTime(DateClicked, vbShortDate)
ctlCalendar.Visible = False
End Sub
Above event is not launched. When I have added a control in "normal way",
on a form - it works. What should be done to get events from dynamically
created control?
Second question: is there any other calendar-control that is more popular?
Application will be installed on systems with Windows2000/Office XP.
Thanks in advance for any help.
TomS
I am preparing small application in VBA for Word (Office 2000/XP) and need
a calendar to pick a date to text field. I tried to use MonthView control,
but it occured that it is not available on some machines. Installing this
ActiveX control on all machines is a big problem - application must work
without installing any additional software.
So I try to make it so, that this control will be shown only when it is
available. I have loaded it dynamically and check if it goes ok. But I
have problem: getting events from control doen't work.
Example code:
Private ctlCalendar As Control
Private Sub UserForm_Activate()
On Error Resume Next
Set ctlCalendar = Me.Controls.Add("MSComCtl2.MonthView.2",
"ctlCalendar", true)
end sub
Private Sub ctlCalendar_DateClick(ByVal DateClicked As Date)
txtDate = FormatDateTime(DateClicked, vbShortDate)
ctlCalendar.Visible = False
End Sub
Above event is not launched. When I have added a control in "normal way",
on a form - it works. What should be done to get events from dynamically
created control?
Second question: is there any other calendar-control that is more popular?
Application will be installed on systems with Windows2000/Office XP.
Thanks in advance for any help.
TomS