userforms

M

merjet

Is there a way to use code to remove userforms in a
workbook?

See comments at start of following Sub.

HTH,
Merjet

Sub DeleteUserForms()
' 1. need to check "Microsoft Visual Basic For Applications
' Extensibility 5.3" at VBE menu Tools | References
' 2. need to check next "Trust access to Visual Basic Project"
' at Excel menu Tools | Macro | Security | Trusted Sources

Dim VBComp As VBIDE.VBComponent
Dim VBComps As VBIDE.VBComponents

Set VBComps = ThisWorkbook.VBProject.VBComponents

For Each VBComp In VBComps
If VBComp.Type = vbext_ct_MSForm Then VBComps.Remove VBComp
Next VBComp

End Sub
 
Top