Clearing data from a Userform when completed

N

nurds

I have created a Word Template using a table that is populated using a
Userform. It all works fine, but when I close the file down and then re-open
it to use it again, the Userform appears with all the previous data still in
it. Am I able to add a line of code that clears all the data from the
userform once the file is closed, thereby leaving a blank userform each time
the file is re-opened? This even applies if I don't save the file upon
closing. Any help on this would be much appreciated.
Thanks.
 
K

Karl E. Peterson

nurds said:
I have created a Word Template using a table that is populated using a
Userform. It all works fine, but when I close the file down and then
re-open it to use it again, the Userform appears with all the
previous data still in it. Am I able to add a line of code that
clears all the data from the userform once the file is closed,
thereby leaving a blank userform each time the file is re-opened?
This even applies if I don't save the file upon closing. Any help on
this would be much appreciated.

Create and use new *instances* of the UserForm, rather than repeatedly
calling the autoinstantiated default instance. IOW, when you want to show
it, do this:

Dim frm As FMyUserForm
Set frm = New FMyUserForm
' set any custom properties
frm.Show

Then, to get rid of it:

frm.Hide 'Assuming this isn't done from within
Set frm = Nothing

Later... Karl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top