Delete Userforms In All Workbooks

Jaye7

Well-known Member
Joined
Jul 7, 2010
Messages
1,069
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

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
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,224,271
Messages
6,177,619
Members
452,786
Latest member
k3calloway

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