M
msdickey
Background: I am trying to create userforms at runtime. I am using the
following code to do so:
Do until frmcount > 5
Set newFrmTemp = ActiveDocument.VBProject.VBComponents.Add(vbext_ct_MSForm)
With newFrmTemp
.Properties("Name") = "frmTemplate" & frmcount
.Properties("Caption") = "Template" & frmcount
.Properties("Height") = 180
.Properties("Width") = 273
End With
frmcount = frmcount + 1
Loop
Question: This creates 5 new userforms. Let's say I run this macro and it
creates all the forms. If I go and delete all of those forms created at
runtime and then try to rerun the macro again I get a Path/File access error.
For some reason it can't recreate those forms with that same name. So, in
other words, everytime I want to rerun the macro I have to close the file and
reopen it to clear those form names.
Why am I having to do that? If I create forms at design and then delete them
I don't have trouble creating a new form with that same name again. What am I
doing wrong? How can I fix it?
following code to do so:
Do until frmcount > 5
Set newFrmTemp = ActiveDocument.VBProject.VBComponents.Add(vbext_ct_MSForm)
With newFrmTemp
.Properties("Name") = "frmTemplate" & frmcount
.Properties("Caption") = "Template" & frmcount
.Properties("Height") = 180
.Properties("Width") = 273
End With
frmcount = frmcount + 1
Loop
Question: This creates 5 new userforms. Let's say I run this macro and it
creates all the forms. If I go and delete all of those forms created at
runtime and then try to rerun the macro again I get a Path/File access error.
For some reason it can't recreate those forms with that same name. So, in
other words, everytime I want to rerun the macro I have to close the file and
reopen it to clear those form names.
Why am I having to do that? If I create forms at design and then delete them
I don't have trouble creating a new form with that same name again. What am I
doing wrong? How can I fix it?