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.
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
75,362
Office Version
365
Platform
Windows
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.:)
 

vijayendra.shukla

New Member
Joined
Jan 29, 2010
Messages
34
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.
 

Forum statistics

Threads
1,081,728
Messages
5,360,923
Members
400,602
Latest member
newaqua

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top