SeniorNewbie
Board Regular
- Joined
- Jul 9, 2023
- Messages
- 71
- Office Version
- 2021
- 2019
- Platform
- Windows
- MacOS
Hi out there,
my project is about creating userforms based on the values in a worksheet. People planning their USFs in advance or work with templates can accelerate the setup in a smart way. The code to create this both items is:
That works very fine. Of course I need to check the layout of the userform and to redesign it, so it's necessary to delete a former version, what's easily done by this code:
My question/problem however: while the code module works perfect the userform runs into an error because somewhere the first userform's name remains in the editor. No idea where.
Anybody out there who knows why usf and mdl react in different way - or how to kill the usf parameters in VBE?
THX a lot and have a wonderful day!
Senior Newbie
my project is about creating userforms based on the values in a worksheet. People planning their USFs in advance or work with templates can accelerate the setup in a smart way. The code to create this both items is:
VBA Code:
' the objects are declared as VBComponent
Set mdl = wb.VBProject.VBComponents.Add(vbext_ct_StdModule)
With mdl
.Properties("Name") = "mdl_DynamicVBA"
End With
Set USF = wb.VBProject.VBComponents.Add(vbext_ct_MSForm)
With USF
.Properties("Name") = "usf_DynamicVBA"
End with
Code:
Sub ResetComponents()
Dim VBComps As VBComponents, VBComp As VBComponent
Set VBComps = wb.VBProject.VBComponents
For Each VBComp In VBComps
If Mid(VBComp.Name, 4, 1) = "_" Or Left(VBComp.Name, 4) = "User" Or Left(VBComp.Name, 5) = "Modul" Then
Set VBComp = VBComps(VBComp.Name)
VBComps.Remove VBComp
Set VBComp = Nothing
End If
Next
End Sub
My question/problem however: while the code module works perfect the userform runs into an error because somewhere the first userform's name remains in the editor. No idea where.
Anybody out there who knows why usf and mdl react in different way - or how to kill the usf parameters in VBE?
THX a lot and have a wonderful day!
Senior Newbie