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?
Word Heretic - 21 Dec 2004 23:25 GMT
G'day "msdickey" <msdickey@discussions.microsoft.com>,
Try unloading the forms instead if setting them to nothing - does that
help? This might be the difference I've been looking for :-)
Steve Hudson - Word Heretic
steve from wordheretic.com (Email replies require payment)
Without prejudice
msdickey reckoned:
>Background: I am trying to create userforms at runtime. I am using the
>following code to do so:
[quoted text clipped - 22 lines]
>I don't have trouble creating a new form with that same name again. What am I
>doing wrong? How can I fix it?