Deleting and importing userform

Wicked_

Board Regular
Joined
Jun 5, 2018
Messages
81
Hi.

Is there a nicer way to use a button on a userform to remove it, and then import it again ?
Lets say i make some changes to the userform, then i export it. Then if i click a button, it shall remove it from the program, and import it again (to get the newest version)

The code i try when pressing the button is:

Code:
Sub removeimport()
Unload UserForm1
Application.VBE.ActiveVBProject.VBComponents.Remove Application.VBE.ActiveVBProject.VBComponents("Userform1")
Application.VBE.ActiveVBProject.VBComponents.Import "O:\Mas\UserForm1.frm"
End Sub

but doing this, i get the error: Run-time error '60061' Error during load.

How can i do this without getting the error ?

EDIT: What i did was to call this code from a module with the button, might be a better way though.
 
Last edited:

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Forum statistics

Threads
1,224,816
Messages
6,181,143
Members
453,021
Latest member
Justyna P

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