Please wait form

J

John

Hi,

Part of my code does much formating etc. of the Word document, so I use
Application.Visible = False to stop the screen flashing madly in front of
the user. It would be nice to have a small form appear with a "Please
wait..." message on it. How can i achieve that and still keep word hidden?

Thanks,

John
 
J

Jezebel

Exactly like that. Even if Word is hidden, userforms will still show. If you
want to be really slick you add a progress bar and a cancel button.
 
H

Helmut Weber

Hi John,

and besides Jezebel's advice,
if you use range instead of selection,
there wouldn't be any activity on the screen
in the first place, probably,
though not all can be done with ranges.
 
J

John

Thanks Jezebel,

I use the following lines.

Application.Visible = False
frmWait.Show

The form shows OK but the text on it doesn't display. If I reverse the order
of the lines, the form doesn't display.

John
 
R

red6000

I'm trying to do exactly the same thing.

On pressing my okay button, the first bit of my code is:

Load PleaseWaitFrm
Application.Visible = False
Application.ScreenUpdating = False
PleaseWaitFrm.Show

then the code runs and does its stuff and then I have the following

Application.Visible = True
Application.ScreenUpdating = True
Application.ScreenRefresh
PleaseWaitFrm.Hide
Unload PleaseWaitFrm

the problem I have is that the hiding of 'PleaseWaitFrm' is not happening
and I have to manually click the x to close it and then word re-appears all
nicely done. So why isn't the hiding of my user form working?

thanks
 
H

Helmut Weber

Hi,

I had to change quite a bit to get a testing environment.

However, I think, you are able to find out what is relevant.

Option Explicit
Public Declare Function GetTickCount Lib "kernel32" () As Long
Sub Test()
Dim l As Long
Dim t As Long
Application.Visible = Not Application.Visible
' strange, but only for testing,
' in case I ran into troubles with visible = false
Frm1.Show vbModeless
Frm1.Repaint
With ActiveDocument
For l = 1 To 10
t = GetTickCount
While t + 1000 > GetTickCount ' slowing down
DoEvents
Wend
Frm1.TextBox1.Text = .Characters(l)
Frm1.Repaint
Next
End With
Application.Visible = True
Unload Frm1
End Sub

At least, this seems to work.
Improvement, best coding according to theory,
is quite another matter.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 

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