Delete Userforms In All Workbooks

Jaye7

Well-known Member
Joined
Jul 7, 2010
Messages
1,060
Can anyone please provide a script that will delete all userforms in all open workbooks except for the workbook it is being run from, it can not be a code that needs to be pasted into a reference via Alt T, it needs to be able to be run as a macro in a userform.

I was provided the following code but it cliches on this line.

code:
For Each VBComp In VBProj.VBComponents

full code follows

code:
Sub RemoveAllUserForms()
Dim VBComp As Object
Dim VBProj As Object

For Each VBProj In Application.VBE.VBProjects
For Each VBComp In VBProj.VBComponents
If VBComp.Type = 3 Then
VBProj.VBComponents.Remove VBComp
End If
Next VBComp
Next VBProj

End Sub
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
It seems to error because some of the running VBA projects on my computer are protected.

I added the line
Code:
On Error Resume Next
after the Dim lines and it seems to work.

What the line does is it tells the macro to ignore errors.
 
Upvote 0
Isn't it On Error GoTo 0?

I really have no idea what it exactly does but I saw it alot so maybe...
 
Upvote 0

Forum statistics

Threads
1,214,590
Messages
6,120,421
Members
448,961
Latest member
nzskater

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