ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   userforms (https://www.excelbanter.com/excel-programming/305058-userforms.html)

Fretsa

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

merjet

userforms
 
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




All times are GMT +1. The time now is 12:02 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com