Change userform code with vba

  • Hi,


    I made an program that has been sent to others to use.


    I found a mistake with one of the userforms code. The form has checkboxes that when checked will print certain sheets. I missnumbered two checkboxes that I need to change. Instead of the code reading "If checkbox35=true then print..." I need to change the checkbox35 to checkbox55.


    What I want to do is send all the users a workbook that will have a command button that when clicked it will go into the program on their computer find the correct userform (userform2) and either fix that one line of code or else just replace the old userform on their computer with the corrected userform that will be contained in the excel workbook I will be emailing them.


    I did something like this when I had to change an incorrect linked reference on the program and I can open workbooks and change things in the worksheets but I don't know how to write a code that will update private code contained in a userform or how to just replace an old module or userform with a corrected one.


    Thank you in advance. Any help would be greatly appreciated.


    Andy

  • Re: Change userform code with vba


    Certainly possible but not really worth doing. You will have issues with this approach. Not firstly around security settings around the IDE but also issues with testing.


    How have you issued this program. As an addin? Can you simply not just reissue it?

  • Re: Change userform code with vba


    As Rich says you could write code to delete the existing UserForm and import a new one. However, you would need a reference to the VBE Properties & there would be issues with different Excel versions. Much easier to send out an update & instructions how to copy & paste existing data into the new workbook, or maybe code to do that.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!