0

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!)

jamheadart
  • 5,047
  • 4
  • 32
  • 63
  • 2
    Check out [How can I create a calendar input in VBA Excel?](https://stackoverflow.com/questions/54650417/how-can-i-create-a-calendar-input-in-vba-excel) which has a nice pure VBA solution for date picking. – Pᴇʜ Jan 11 '21 at 09:54
  • Ha I was hoping to use something that exists already on my laptop but I guess copy and pasting a whole bunch of stuff will do! – jamheadart Jan 11 '21 at 10:09
  • well there exists the datepicker from the MSCOMCT2 see [How to Add Date Picker To VBA UserForm](https://stackoverflow.com/questions/13409653/how-to-add-date-picker-to-vba-userform) but it is a pain in the a… – Pᴇʜ Jan 11 '21 at 10:11

1 Answers1

1

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.

Wolff68
  • 11
  • 4
  • 2
    Please read [answer] and [Are answers that just contain links elsewhere really "good answers"?](https://meta.stackexchange.com/q/8231/248627) We expect answers to be useful on their own, even if all links break. – ChrisGPT was on strike Oct 23 '21 at 23:45