UserForm problem

S

sweet_dreams

Hi all,

I have problem with userforms in Word.

I have a template in which I have such a macro:

Sub AutoNew()

Application.Visible = False
UserForm1.Show
Dim i As Integer
For i = 1 To 10000
' some code
Next i
Unload (UserForm1)
Application.Visible = True

End Sub

So everytime when I open new doc based on this template UserForm1 is
shown.
But unfortunately userform1 doesn't diasapear. When I try to close it
manualy I get error: "Can't load or unload this object."
So my question is how can I close programmaticaly Userform after some
code have been executed, like in my example.

Whats more I noticed that code in loop is executeg when I close this
UserForm.
What I would like to achieve is to perform some code when Word is not
visible. I need UserForm to show progess of this actions and show
information connected with what is done. But unfortunately I can't show
any code on Label which is placed on form beacuse code in loop is
executed when form is closed. Can somebode give me any clue how can I
achieve what I wanted.

Regards,
sweet_dreams
 
P

Peter

You should execute your code in the userform. Either in the activate event of
the form or in the click event of a command button. Your AutoNew procedure
would have only a single line; namely: Userform1.Show

Peter
 

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