Using a progress bar with the save command

RoyR

Board Regular
Joined
Jan 25, 2012
Messages
62
I have some very large workbooks that take a long time to save. Because of this, I made a simple form to use as a message box to state that the file is being saved. This works fine. But, just for fun and experence, I was wondering if a progressbar can be added. Below is the code being used.

Code:
Msg_Saving_Files.Show False 'Show message that the program is saving
        
 Application.Wait Now + TimeSerial(0, 0, 1) 'Wait 1 second before next command _
                                                               If this is not used, then the _
                                                               form is blank for some reason
 ActiveWorkbook.Save 'Save the workbook
 Unload Msg_Saving_Files 'Remove the "Saving File" message

From what I read about the progress bar, you need to set points in the program where it is updated. That can not be done with this simple code. Is there anything that can be done?

Thanks in advance

Roy
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
To use a progress bar you need to update it as the operation which you're reporting on is proceeding. For example, if you're processing a hundred records, you start the progress bar at zero and add one every time you process one of the records, and the on-screen progress bar updates. When you reach a hundred, the progress bar is 'full'.

The problem you've got is that when the file is saving, VBA isn't executing - the operating system takes over and VBA pauses until the save operation has completed - so you can't update the progress bar, even with VBA which is more complex that the snippet you've shown above. You would have to write some code which was capable of running in parallel with the save operation and as far as I'm aware, this would involve writing an interrupt handler (Interrupt handler - Wikipedia, the free encyclopedia). I've done it in Assembler - I wouldn't have a clue where to start with Windows.

Can anyone correct me or add to this?
 
Last edited:
Upvote 0
That is what I figured but I thought I would see if someone out there found a way. I do enjoy to try out new ideas and new code. It is the best way for myself to learn it. Thanks for taking the time to respond.

Roy
 
Upvote 0
That's how I've learned - read a bit in the forum, have a bit of a tinker, use Google to fill in the gaps, ask questions here if necessary.

I'm hoping someone else will come up with a solution though, as I really fancy the idea of learning how to do a bit of interrupt-driven processing.

Keep bumping the thread! ;)
 
Upvote 0

Forum statistics

Threads
1,206,920
Messages
6,075,573
Members
446,147
Latest member
homedecortips

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top