Runtime Error 1004 in dynamic UserForm

vijayendra.shukla

New Member
Joined
Jan 29, 2010
Messages
34
Hi all,

I am using a code available on one of the sites for creating a dynamic user form. but i am not able to proceed at all because of Runtime Error 1004 "Application Defined or Object Defined error".

here is the part where i am getting it:
Code:
Sub MakeUserForm()
    Dim TempForm As Object
    Dim NewLabel As MSForms.Label
    Dim NewComboBox As MSForms.ComboBox
    Dim NewButton As MSForms.commandbutton
    Dim NewCheckBox As MSForms.CheckBox
    Dim X As Integer
    Dim iNoOfSheets As Integer
    Dim iTotalRows As Integer
 
    'This is to stop screen flashing while creating form
 
    Application.VBE.MainWindow.Visible = False
 
   Set TempForm = ThisWorkbook.VBProject.VBComponents.Add(3)

FYI - I have included the necessary libraries eg. MS Form,Object lib, VBA.

Thanks in advance for your time and help.
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Hi,

Do you have "Trust Access to Visual Basic" checked in your Macro Security - Trusted Publishers section?
 
Upvote 0
Hi,

Do you have "Trust Access to Visual Basic" checked in your Macro Security - Trusted Publishers section?

Hey Mike, just now i checked the box under Macro Settings -> Developer Macro Settings -> "Trust access to the VBA project object model" and you know what i did not get any error this time. What i have done right now, is correct? Was this the problem?
 
Upvote 0
Hi,

Sorry so used to 2003, I'm assuming your on 2007 or 2010. Yeah, you need to check the Trust Access to VB button to be able to alter/add components to projects, import modules etc.
 
Upvote 0

Forum statistics

Threads
1,223,244
Messages
6,170,976
Members
452,372
Latest member
Natalie18

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