Consulting

Results 1 to 6 of 6

Thread: Solved: Waiting Form while macro Runing

  1. #1
    VBAX Mentor fredlo2010's Avatar
    Joined
    Dec 2011
    Location
    Florida, USA
    Posts
    374
    Location

    Solved: Waiting Form while macro Runing

    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

    [VBA]

    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
    [/VBA]

    Any ideas?
    Feedback is the best way for me to learn


    Follow the Armies

  2. #2
    VBAX Master
    Joined
    Feb 2011
    Posts
    1,475
    Location
    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.

    [VBA]
    Sub StatusBarTest
    Dim i as integer

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

  3. #3
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    2,727
    Location

    Demo Modeless Form

    [VBA]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
    [/VBA]


    Quote Originally Posted by fredlo2010
    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

    [vba]

    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
    [/vba]

    Any ideas?
    Greg

    Visit my website: http://gregmaxey.com

  4. #4
    VBAX Mentor fredlo2010's Avatar
    Joined
    Dec 2011
    Location
    Florida, USA
    Posts
    374
    Location
    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 :?


    This what I should see



    This is what I get

    Feedback is the best way for me to learn


    Follow the Armies

  5. #5
    VBAX Master
    Joined
    Feb 2011
    Posts
    1,475
    Location
    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.

  6. #6
    VBAX Mentor fredlo2010's Avatar
    Joined
    Dec 2011
    Location
    Florida, USA
    Posts
    374
    Location
    Forty yeah it works now.. perfect.

    Thanks for the help once again
    Feedback is the best way for me to learn


    Follow the Armies

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •