Runtime error 50289

vijayendra.shukla

New Member
Joined
Jan 29, 2010
Messages
34
Hi,

I am trying to generate a dynamic user-form via vb code. I have protected the code module using VBA Project Properties. But when I re-open the workbook and run the code, I am getting the
"Runtime error - '50289' - Application defined or Object defined error.".

When I tried putting some msgbox after particular lines, i got to know that error is coming while executing the below given line:
Code:
Set TempForm = ThisWorkbook.VBProject.VBComponents.Add(3)
Here TempForm is defined as Object using Dim statement.

I am not sure why it is showing this error for this particular line.

But When code is not protected, it runs fine without any error. Is there any way that I can protect my code without getting into this error.

Thanks for your help and time.
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
This may seem like a strange question but, why are you generating userforms dynamically?

Also why are you protecting the code?

If you do want to protect and then use this code you would have to unprotect, run the code then re-protect.

As far as I know there is no reliable way to do that programatically, you could try SendKeys I suppose.:)
 
Upvote 0
Thanks Norie for your response.

I am generating UF dynamically because the data i want to display is not constant, and it keeps on changing for different input values.

I am protecting the code from anyone modifying it accidentally. That is why I have Locked the project from viewing.

Also can you please help me on how to use SendKeys here in this case.

Thanks.
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,964
Members
452,371
Latest member
Frana

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top