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
 

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
Record a macro and insert the date control while recording the macro. That will give you the vba code you need to add the date control.
 
Upvote 0
Ok, I can see now that you were asking about XL2K3. What I was saying to do works in Excel2007. When you say it doesn't work, do you mean that when you try to record the macro it doesn't capture the you adding the date control? Or does it capture the macro but when you try to use what has been recorded it doesn't insert the date control?
 
Upvote 0
If it works in 2k7, could you please post the code generated, thanks.

Sure, here you go. Note that you might have to change the name of the control to the control name that is available in XL2K3.

Sub insertDatePicker()
'
' insertDatePicker Macro
'

ActiveSheet.OLEObjects.Add(ClassType:="MSComCtl2.DTPicker.2", Link:=False, _
DisplayAsIcon:=False, Left:=192.75, Top:=44.25, Width:=95.25, Height _
:=16.5).Select
End Sub
 
Upvote 0
Hi Vladislav,
Would you care to post the tweak that you used for the userform datepicker?
Trying to load the DatePicker onto a userform at design time is driving me crazy :-)
Regards
John
 
Upvote 0
John

Just change ActiveSheet.OLEObjects to Me.Controls.
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,849
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