jamheadart
jamheadart

Reputation: 5323

DatePicker in an Excel UserForm - Outlook controls?

I've just tried to add an OlkDateControl to my Excel VBA UserForm but it tells me it can't load the control.

I had the control in my Toolbox already, and I'm pretty sure I've used it before but can't figure out how.

I've made sure this new workbook has Outlook 16.0 Object Library in the references

From an MS VBA API guide:

You can only add this control to a form region in an Outlook form using the forms designer; you cannot add this control to a Visual Basic UserForm object in the Visual Basic Editor.

I don't really know what this means - What is a form region? Can I create an Outlook form in Excel?

I tried creating it at run time:

Private Sub CommandButton1_Click()
Dim x As New OlkDateControl
    x.Value = "01/01/2021"
End Sub

Which runs fine but there's no sort of x.Show or way to show the control on the UserForm.

I also tried adding it to the UserForm

Dim x As New OlkDateControl
Set x = UserForm1.Controls.Add("OlkDateControl")

Any ideas?

(Or a good DatePicker alternative would also be great!)

Upvotes: 1

Views: 5173

Answers (1)

Wolff68
Wolff68

Reputation: 11

I was annoyed to search for controls, install libraries or manage class modules. Therefore I have programmed my own DatePicker, which only needs a single userform. Just importing the frmWMDatePicker.frm (and its .frx of course) a function frmWMDatePicker.GetDate is provided which will open a userform to pick a date.

I provide my frmWMDatePicker at https://1drv.ms/f/s!AtjCbB-8TbkNgogTYGtFivQhi_kipQ There's also an Excel workbook for testing and description.

Upvotes: 1

Related Questions