Create DatePicker on the fly in XL2K3

Vladislav

New Member
Joined
Aug 21, 2011
Messages
33
Hi everyone,

I'm looking for a way to create a date picker control in a userform on the fly in XL2K3. My preference is to use the .add method and a progID like to labels, textboxes, etc.. However, I don't know the date picker progID or whether this can be done that way.

It is possible to create date picker at design time, hide and then show when needed, but I'd rather not do that if I can avoid it.

Your help appreciated!

cheers,
Vlad
 
Hi Norie,
Thanks for responding.
Unfortunately that did not work, it showed as a failure to recognnise 'ClassType'.
Regards
John
 
Upvote 0

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
John

Do you have the DTPicker installed?

By the way, why do you want to add? Couldn't you just have it on the form and hidden, or even on another form?
 
Upvote 0
John

Do you have the DTPicker installed?

By the way, why do you want to add? Couldn't you just have it on the form and hidden, or even on another form?

Hi Norie,
Yes, I have DTPicker installed, referenced and registered and it does work when loaded onto a form manually.
The program will be used by different users under varying circumstances that require differing Form layout, and so needs to be built on the fly.
Regards
John
 
Upvote 0
For anyone interested, the solution is:
Sub DesignTimeDatePicker()
'Adds a DatePicker at design time

Dim dtpCal As DTPicker

Set dtpCal = ThisWorkbook.VBProject.VBComponents("frmDEntry").Designer.Controls.Add("MSComCtl2.DTPicker.2")
With dtpCal
.Name = "dptTransDate2"
.Format = dtpLongDate
.Left = 90
.Width = 192
.Top = 126
.Height = 18
End With
End Sub

With thanks to Microsoft Help Desk
 
Upvote 0

Forum statistics

Threads
1,224,605
Messages
6,179,860
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top