+ Reply to Thread
Results 1 to 16 of 16

Progress Indicator code placement

Hybrid View

  1. #1
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,026

    Progress Indicator code placement

    Hi All

    I got code for a progress Indicator from the Excel Easy website but I'm not certain where to put my specific code which will allow for the indicator to run. All i want to do is show the progress indicator running while workbook is saving. Any feedback please.

    UserForm55 is my Progress Indicator with the following code:
    Private Sub UserForm_Activate()
    code
    End Sub
    Herewith the code for Code Module
    Sub code()
    Dim i As Integer
    Dim pctCompl As Single
    For i = 1 To 100
    'ActiveWorkbook.Save
    Unload UserForm55
    pctCompl = i
    progress pctCompl
    Next i
    End Sub
    Herewith the code for Progress Module
    Sub progress(pctCompl As Single)
    UserForm55.TEXT.Caption = pctCompl & "% Completed"
    UserForm55.BAR.Width = pctCompl * 2
    DoEvents
    End Sub

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Progress Indicator code placement

    You cannot run other code while Excel is busy saving your workbook. A consequence of the way Excel is built.

    The best you can do is make sure the StatusBar at the bottom of the Application Window is visible. That shows a progress bar while a large file is saved.

  3. #3
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,026

    Re: Progress Indicator code placement

    Hi cytop

    Thanks for response. Unfortunately, my UserForm will be in fullscreen mode. No status bar visible.

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    27,191

    Re: Progress Indicator code placement

    Your problem is a little confusing. Judging by your code, you want to save the same workbook 100 times. It doesn't make sense to me why you would do that. Each time you save it is another 1% complete. You want a progress bar to show that completion. However, you Unload the form every time through the loop, and you never Show it.

    I recommend you use the standard practice of indentation to reflect the structure of your code. I think your code needs to look like this, but I can't test it without your file. You also need to configure the Properties of your form to be ShowModal = False.

    Sub code()
    
       Dim i As Integer
       Dim pctCompl As Single
    
       progress 0
       UserForm55.Show
    
       For i = 1 To 100
          'ActiveWorkbook.Save   
          pctCompl = i
          progress pctCompl
       Next i
    
       Unload UserForm55
    
    End Sub
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  5. #5
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,026

    Re: Progress Indicator code placement

    Hi Jeff

    You are absolutely right. i noticed that afterwards. I got confused with the code taken from the site....Thought one would have to put the progress in a loop.
    As per cytops response "You cannot run other code while Excel is busy saving your workbook. A consequence of the way Excel is built". I guess it would not work anyway.

    Is there a way to hava a message pop up while the book is saving and then close once done.

  6. #6
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Progress Indicator code placement

    No progress bar is visible then - blame Mr Gates.

  7. #7
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,026

    Re: Progress Indicator code placement

    True lol

    Thanks anyway...Back to the drawing board unless I can just have a MsgBox come up to say save in progress and the go away when done

  8. #8
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Progress Indicator code placement

    You can't use a MsgBox as that will be Modal and pause all other code until the MsgBox is cleared by the user. Simplest option is to use a userform with an appropriate message showing and displayed Modelessly (Otherwise you hit the same problems as the messagebox).

  9. #9
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,026

    Re: Progress Indicator code placement

    I am able to do a UserForm, but how to get it to show while and during up until workbook is saved then to unload

  10. #10
    Forum Contributor
    Join Date
    07-23-2016
    Location
    Texas
    MS-Off Ver
    2016
    Posts
    274

    Re: Progress Indicator code placement

    Before starting the save, show the notice form with the vbModeless parameter, i.e.

    myNoticeForm.Show vbModeless

    Then after the save, hide the form

    myNoticeForm.Hide or myNoticeForm.Unload

  11. #11
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,026

    Re: Progress Indicator code placement

    Why if my UserForm has a label saying Save in Progress, Does the "Save in Progress not show" when calling Userform

  12. #12
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,026

    Re: Progress Indicator code placement

    Hey guys

    Does the VbModeless not allow for label or TextBox show

  13. #13
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,026

    Re: Progress Indicator code placement

    Can you perhaps explain how to go about doing that ....pretty please

  14. #14
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,026

    Re: Progress Indicator code placement

    Awesome
    Thanks EssoExplJoe...Will give it a try

  15. #15
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Progress Indicator code placement

    Does the VbModeless not allow for label or TextBox show
    It does.

    What's happening is probably that you show the userform and then immediately save the file or do other processing. VBA is an absolute hog when it comes to resources and memory use so when the userform is loaded Windows is 'told' to refresh the screen (or at least that part occupied by the userform). Because your code continues immediately Windows never finds an idle millisecond or 3 to refresh the screen - so you have to tell your code to cede processor time to Windows.

    myNoticeForm.Show vbModeless
    DoEvents
    '// code continues
    The DoEvents allows Windows to catch up with all outstanding tasks - like screen updating. It does introduce a slight delay but is unnoticeable in a single call like that.
    Last edited by cytop; 09-30-2016 at 12:40 PM.

  16. #16
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,026

    Re: Progress Indicator code placement

    Thanks Cytop

    Got it working. Code is as follows with Userform55 containing Label "Save in progress"

    Private Sub CommandButton4_Click()
    Application.ScreenUpdating = False
    Unload Me
    UserForm55.Show vbModeless
    DoEvents
    ActiveWorkbook.Save
    Unload UserForm55
    UserForm22.Show
    Application.ScreenUpdating = True
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Progress Indicator help
    By SUMIF in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-27-2016, 09:20 AM
  2. Progress Indicator
    By julhs in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-15-2016, 01:17 PM
  3. Donut Style Progress Indicator not executing while other code is running
    By UCAnalytics in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-22-2013, 05:20 AM
  4. Progress Indicator Bar
    By abousetta in forum The Water Cooler
    Replies: 17
    Last Post: 10-01-2012, 03:34 AM
  5. Status bar progress indicator stops updating part way through code execution.
    By maacmaac in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-08-2012, 07:45 PM
  6. Progress Bar Indicator
    By coneill0422 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-06-2011, 07:18 PM
  7. Progress Indicator
    By excel_lover in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-20-2009, 04:59 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1