Importing userform then run the code within the userform.

Wicked_

Board Regular
Joined
Jun 5, 2018
Messages
81
Hi.

So i got a userform in one of my folders, and i want it so, that everytime i start up the excel program, it imports that form, then run the code inside the form as normal.

So far i got this:

In ThisWorkbook i got:

Private Sub Workbook_Open()
Dim fso: Set fso = CreateObject("Scripting.FileSystemObject")
Application.VBE.ActiveVBProject.VBComponents.Import "O:\Mask9\Dash\Main.frm"

And in the Main.frm i got any "random" code that it does, but that shouldent matter here (as far as i know)

But when i run this program i get this error: Run-time error '424': Object required.

I even tried adding Application.Wait (Now + TimeValue("0:00:02")) in the ThisWorkbook, to "force it" to import, before the Main.frm run its code., but i still got the error the second i opened it.

When i press end (debug is greyed out), i see that the main.frm is loaded, but it seems like it wont run the code after it as been imported.

Is there a way to fix this issue?

Thanks :)
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Forum statistics

Threads
1,213,494
Messages
6,113,981
Members
448,538
Latest member
alex78

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