none
How to create a custom date picker control and use it in MS Excel UserForm

    Question

  • Hi,

    I want to create a .NET DatePicker Control and use it in MS Excel User Form to select the dates.

    How to do this in C#? 

    Please guide me on this.

     


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This will help other members to find the solution easily.
    • Moved by CoolDadTxMVP Tuesday, December 27, 2011 6:00 PM Office related (From:Visual C# General)
    Tuesday, December 27, 2011 4:39 PM

Answers

  • Hi,

    I apologies for getting back late.

    Your project target platform was set to AnyCPU, which is good.

    Also, when register such Activex control, we will need to register on both 32bit and 64bit command prompt. Register twice, then registry will be written to both 64bit and WOW6432. In VS 2010, we could found them in start menu. Please let me know if you ran into problems.

    Best Regards,


    Forrest Guo | MSDN Community Support | Feedback to us

    Monday, January 09, 2012 8:20 AM
  • Hi, I'm writing to let you know that I try to get other people help on this problem. Thank for for your patience.

    I noticed you have uploaded one project to Skydrive, it would be helpful to share both the downloaded sample and customized sample control, tell which is which.

    The VBA macros in your workbook is very key in Excel runtime error 459 either. I would suggest you add activex controls to a clean workbook without macros, this can tell us if the problem lies in macro or activex control.

    Also, I noticed you have a new thread relates to this issue.  Our engineer will investigate and follow one of them. It is suggested that we close this one and follow up this: http://social.msdn.microsoft.com/Forums/en-US/isvvba/thread/35fa7a48-6319-4fc4-8d53-e20e7f08e6d2

    Best Regards,

     


    Forrest Guo | MSDN Community Support | Feedback to us

    Thursday, January 12, 2012 2:22 AM

All replies

  • Check below thread
    http://social.msdn.microsoft.com/forums/en-US/vsto/thread/06225ee0-f799-440d-8ae7-f387709a1054/

    Rozy
    Tuesday, December 27, 2011 5:44 PM
  • Hi,

    I don't want it keep datepicker in MS Excel cell.

    I want to use my own datepicker in MS Excel UserForm. There is a difference between both.

    Hope now it is clear!

    Thanks in advance


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This will help other members to find the solution easily.
    Wednesday, December 28, 2011 2:33 AM
  • Hi,

    Excel User Form accept ActiveX controls, you can create the date picker as ActiveX control, then register it in the Toolbox of User Form.

    About how to create an ActiveX control in .NET, you can refer to: http://www.c-sharpcorner.com/UploadFile/dsandor/ActiveXInNet11102005040748AM/ActiveXInNet.aspx

    Then you can register like below picture.  Please let me know if there's anything unclear, I'll try my best to assistant.


    Forrest Guo | MSDN Community Support | Feedback to us

    • Proposed as answer by Thomas W Marshall Monday, January 02, 2012 2:36 PM
    • Unproposed as answer by ksvimal Monday, January 02, 2012 4:50 PM
    Saturday, December 31, 2011 6:14 AM
  • Hi Guo,

    Thanks for your guidance.

    I have downloaded the sample and tried to register as per your instruction.

    But while registering, I got the error “The selected file does not contain any self-registering ActiveX controls.”


    I have modified the sample and added COM attributes and self-registering methods.

    Now, I am able to register in 32bit MS Excel (i.e MS Office 2010 32 bit) but still I am getting the same error in 64bit MS Excel (i.e MS Office 2010 64 bit).

    I have uploaded the modified code for your reference. Please download from the following path.

    https://skydrive.live.com/?cid=ab034720ad5419bf&sc=documents&id=AB034720AD5419BF%21147#cid=AB034720AD5419BF&id=AB034720AD5419BF%21326&sc=documents

    I would like to have only one ActiveX control (i.e only one dll file) which should be registered in both 32 bit and 64 bit office.

    Note:

    In 64 bit office, I am able to register the 64 bit ActiveX control by executing the below command in CMD and without any self-registering  function in the ActiveX control.

    RegAsm.exe ActiveXDotNet.dll /codebase

    But samething didn’t work in 32 bit office.

    Can you please check my code and give feedback? Please how to make the same ActiveX control work in both 32 bit and 64 bit office. Also I prefer to register the Activex through command prompt.

     

     


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This will help other members to find the solution easily.
    Monday, January 02, 2012 7:35 AM
  • Can anyone help me on this?


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This will help other members to find the solution easily.
    Thursday, January 05, 2012 10:43 AM
  • Hi,

    I apologies for getting back late.

    Your project target platform was set to AnyCPU, which is good.

    Also, when register such Activex control, we will need to register on both 32bit and 64bit command prompt. Register twice, then registry will be written to both 64bit and WOW6432. In VS 2010, we could found them in start menu. Please let me know if you ran into problems.

    Best Regards,


    Forrest Guo | MSDN Community Support | Feedback to us

    Monday, January 09, 2012 8:20 AM
  • Hi,

    Thanks for your reply.

     

    Can you please let me know how to create msi installer file with VS setup project.

    I have uploaded my project under the following path.

    https://skydrive.live.com/#cid=AB034720AD5419BF&id=AB034720AD5419BF%21326

     


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This will help other members to find the solution easily.
    Monday, January 09, 2012 3:21 PM
  • Sure. I got your project. To create msi installer, following article is very helpful guidence: http://msdn.microsoft.com/en-us/library/2kt85ked.aspx General points are:

    1. Add project output to setup project Files; That's the activex control dlls
    2. Config activex registeration in setup project post-build event.

    Have you been able to register on both 32bit and 64bit now?

    Best Regards,


    Forrest Guo | MSDN Community Support | Feedback to us

    Monday, January 09, 2012 3:38 PM
  • Yes, I am able to register on both 32 bit and 64bit now.

    I created the MSI file by making the assembly with vsdraCOM.

    But nothing happens after installation.


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This will help other members to find the solution easily.
    Monday, January 09, 2012 5:05 PM
  • So I think you register the activex control manually and it works for both 32bit and 64bit Excel. The control could be found in "More Controls" dialog. Please let me know if I misunderstood.

    The current question becomes more about setup and deployment. By running msi installer, it's expected that activex related files (.dll, .pdb, .tlb...) are copied to specified folder. dll file are registered as COM object.

    Another option in setup project, you may try to add related files explictly, instead add project output group. This way, you specify .dll, .pdb, .tlb etc

    Best Regards,


    Forrest Guo | MSDN Community Support | Feedback to us

    Tuesday, January 10, 2012 2:07 AM
  • Hi

    Thanks.

    I have one problem.

    Now I am able to get the COM control in 64 bit office by registering assembly with 64 bit Regasm and then with 32 bit Regasm.

    I placed the COM control in the MS Excel UserForm.

    when i try to run the UserForm, I am getting "Run-time error '459: External Exception'"

    But it works fine without any error in 32 bit office.

    Any idea why i get this error?

     


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This will help other members to find the solution easily.
    Tuesday, January 10, 2012 4:02 AM
  • I searched around and found that this is a VBA runtime error. Error 459 indicates: This component doesn't support events (version 97). Do you have macro along with the excel workbook?

    You may try to register the activex control for 64bit Excel again. Refer to this thread: http://social.msdn.microsoft.com/Forums/en-US/isvvba/thread/fb127ec4-f907-4e61-ac2d-87e75e67c1a9/

    Reference:

    http://support.microsoft.com/kb/146864

    Best Regards,


    Forrest Guo | MSDN Community Support | Feedback to us

    Tuesday, January 10, 2012 6:37 AM
  • Yes I have macro along with the workbook.

    I am just opening a user form and the user form has my control. thats it nothing else.

    It is working in my 32 bit machine but not in the 64 bit machine.

    I really dont know what is the exact problem. I tried register again but still that didnt help me anyway :(

     

     


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This will help other members to find the solution easily.
    Tuesday, January 10, 2012 8:03 AM
  • Now it turns out the obstacle lies in VBA specifically.  Would you please wrap up this thread and create a new thread in VBA forum?  http://social.msdn.microsoft.com/Forums/en-US/isvvba/threads

    Best Regards,


    Forrest Guo | MSDN Community Support | Feedback to us

    Wednesday, January 11, 2012 2:49 PM
  • Hi Guo,

    Thanks for your continuous support and I really appreciate it.

    I have two sample solutions.

    first one i have downloaded from internet and i modified it.

    second one i have created by looking into the first sample.

    first sample works fine in both 32 bit and 64 bit.

    but the second one works only 32 bit and in the 64bit i am getting the error "Run-time error '459: External Exception'"

    I have compared both the samples, I don't find any difference between them but it doesn't work.

    So I still believe i am doing something wrong in my COM control.


     


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This will help other members to find the solution easily.
    Wednesday, January 11, 2012 3:15 PM
  • Hi, I'm writing to let you know that I try to get other people help on this problem. Thank for for your patience.

    I noticed you have uploaded one project to Skydrive, it would be helpful to share both the downloaded sample and customized sample control, tell which is which.

    The VBA macros in your workbook is very key in Excel runtime error 459 either. I would suggest you add activex controls to a clean workbook without macros, this can tell us if the problem lies in macro or activex control.

    Also, I noticed you have a new thread relates to this issue.  Our engineer will investigate and follow one of them. It is suggested that we close this one and follow up this: http://social.msdn.microsoft.com/Forums/en-US/isvvba/thread/35fa7a48-6319-4fc4-8d53-e20e7f08e6d2

    Best Regards,

     


    Forrest Guo | MSDN Community Support | Feedback to us

    Thursday, January 12, 2012 2:22 AM
  • I am a beginner but since I use lotus 123 to excel-10, I have always liked to create functional spreadsheets, macros and forms of personal use of my projects, on the other side whenever there is a jump back I have to learn is to have the same product to regain the ability to excel development, ksvimal Friend, I do not know how to install the patch, please indicate in any way or recommend any title to read it. Thank you very much in advance.
     If you get errors because I do not speak much English **

    Sunday, May 27, 2012 8:06 AM