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

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Forum statistics

Threads
1,214,411
Messages
6,119,360
Members
448,888
Latest member
Arle8907

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