Share via

DatePicker in Excel VBA

Anonymous
2024-04-03T16:14:26+00:00

Hello, I'd like to add the "DatePicker" control to a UserForm in Excel VBA. My PC is running Windows 11 64 bits. I tried to download and install the mscomct2.ocx file but it doesn't work.

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

3 answers

Sort by: Most helpful
  1. Anonymous
    2024-04-03T16:59:42+00:00

    Hi, thank you for reaching out. My name is Deeksha and I'm a Microsoft user like yourself and I will try to help you as best as I can today.

    Adding the "DatePicker" control to a UserForm in Excel VBA on a Windows 11 64-bit system involves several steps, especially if you're having issues with the mscomct2.ocx file.

    Downloading the mscomct2.ocx File: Ensure you download the mscomct2.ocx file directly from Microsoft's official website

    Installing the OCX File: First, you need to copy the mscomct2.ocx file to the correct directory. For a 64-bit system, this is usually C:\Windows\SysWOW64. Once the file is in the right directory, you must register it. To do this: Open the Command Prompt as an administrator (search for "cmd" in the Start menu, right-click on it, and select "Run as administrator").

    In the Command Prompt, type the following command and press Enter: regsvr32 C:\Windows\SysWOW64\mscomct2.ocx

    You should receive a success message confirming that the OCX has been registered.

    Adding the DatePicker Control to the UserForm: Open Excel and go to the VBA editor (Alt + F11). In the VBA editor, open the UserForm where you want to add the DatePicker control. Right-click on the Toolbox and select "Additional Controls." From the list, look for "Microsoft Date and Time Picker Control 6.0 (SP6)" and check the box next to it. The DatePicker control should now be available in the Toolbox, and you can add it to your UserForm.

    Troubleshooting: If the OCX file is not registering, make sure you're running the Command Prompt as an administrator. Check if your antivirus software is blocking the OCX file. Some antivirus programs can mistakenly flag these files as suspicious. Ensure you have the necessary administrative permissions on your PC to install and register OCX files.

    Alternatives: If you continue to face issues, you might consider using a different method to implement a date picking functionality, such as using a combination of TextBox and Calendar controls, or exploring third-party date picker controls that are compatible with Excel VBA.

    Try these steps and hopefully, it resolves your issue. In case you need further help or assistance, please let us know. You can also contact Microsoft Support if the problem persists.

    Best regards Deeksha

    2 people found this answer helpful.
    0 comments No comments
  2. Anonymous
    2024-04-04T10:59:11+00:00

    No worries!

    0 comments No comments
  3. Anonymous
    2024-04-04T09:28:02+00:00

    Hello

    Thanks a lot. I will try. I tell you if it's OK.

    Best regards

    0 comments No comments