PDA

View Full Version : Solved: Waiting Form while macro Runing



fredlo2010
04-30-2012, 06:36 AM
Hello,

I am trying to create this form that will show on the screen while my macro is running to keep the user informed of whats going on. I don't want anything facy just a simple form with a picture and text. Maybe three dots at the end of the label that appear and disappear, but this is completely optional.

My main issue here is that i cannot get it to work. The form loads but it never disappears from screen. My word application freezes.

Here is my code



Sub FormTryout()

Load WaitingForm
WaitingForm.Show

'MAKE BOLD THE VALID TIME

Dim rngLook As Range

Set rngLook = ActiveDocument.Content

rngLook.Find.ClearFormatting
rngLook.Find.Replacement.ClearFormatting
rngLook.Find.Replacement.Font.Bold = True
With rngLook.Find
.Text = "Make this text Bold"

End With
rngLook.Find.Execute Replace:=wdReplaceAll

WaitingForm.Hide

End Sub


Any ideas? :dunno

Frosty
04-30-2012, 09:16 AM
There is a property on the userform called "ShowModal" ... you want to False. Check the help file.

Another option is to simply use the Application.StatusBar (check the help file on this) to provide updating as your code runs. This removes the complexity of understanding non-modal userforms (and when to dismiss the userform).

Try the following code, to see if .StatusBar would do enough for you.


Sub StatusBarTest
Dim i as integer

for i = 1 to 1000
application.StatusBar = "Hello, processing " & i
Next
End Sub

gmaxey
04-30-2012, 10:18 AM
Sub UFDemo()
Dim i As Long
UserForm1.Show vbModeless
Application.ScreenRefresh
For i = 1 To 10000
UserForm1.Caption = "I'm running as fast a can!! " & 10000 - i & " steps to complete."
DoEvents
If i = 10000 Then Unload UserForm1
Next
End Sub




Hello,

I am trying to create this form that will show on the screen while my macro is running to keep the user informed of whats going on. I don't want anything facy just a simple form with a picture and text. Maybe three dots at the end of the label that appear and disappear, but this is completely optional.

My main issue here is that i cannot get it to work. The form loads but it never disappears from screen. My word application freezes.

Here is my code



Sub FormTryout()

Load WaitingForm
WaitingForm.Show

'MAKE BOLD THE VALID TIME

Dim rngLook As Range

Set rngLook = ActiveDocument.Content

rngLook.Find.ClearFormatting
rngLook.Find.Replacement.ClearFormatting
rngLook.Find.Replacement.Font.Bold = True
With rngLook.Find
.Text = "Make this text Bold"

End With
rngLook.Find.Execute Replace:=wdReplaceAll

WaitingForm.Hide

End Sub


Any ideas? :dunno

fredlo2010
04-30-2012, 01:09 PM
Hi guys,

I implemented the suggestion provided by Frosty and it works. Well at least the fact that the form shows up while the macro is running. The problem now is that does not show any content only a white form. I am still using the original code the only thing I changed was the form property "ShowModal" false.

The status bar doesn't work for me. I can only see the end part the beginning is just flickering text. I prefer the form

By the way Frosty, the macro thats running behind the form is one someone help me out with...I dont know who :? :rotlaugh:


This what I should see

http://i45.tinypic.com/2sgmw.jpg

This is what I get

http://i49.tinypic.com/ji2ik7.jpg

Frosty
04-30-2012, 01:22 PM
Try putting

WaitingForm.Repaint
or
Application.ScreenRefresh

in a couple of different places. My guess is that your Application.ScreenUpdating = False may be adversely impacting this the updating of your form.

fredlo2010
04-30-2012, 01:27 PM
Forty yeah it works now.. perfect.

Thanks for the help once again