sykes
Well-known Member
- Joined
- May 1, 2002
- Messages
- 1,885
- Office Version
- 365
- Platform
- Windows
Hi Folks
Does anyone know if it's possible to use "ActiveWorkbook.Save" then have a loop running until the workbook's finished saving?
I'm trying to design a "Saving indicator" - a bit like a progress bar but with dots appearing in a line.
The code below works well. It's called from a userform (userform4).
On the userform are 3 labels.
One ("mess") contains the caption - either "Please wait - saving workbook", or "Workbook saved."
The other 2 are laid one on top of the other. Both have the same background colour as the userform. The bottom one contains a row of dots. As the loop progresses it moves the top one ("waiting") to the right and slowly reveals the line of dots.
When the loop's been through 20 iterations it re-sets everything and starts again.
At the moment it does this five times (the outer loop) then stops.
What I'm trying to achieve is to start this loop when I start saving the workbook (it's taking about 10 seconds to save at the moment, but this will increase as it gets bigger) and exit it when the save has finished.
I've already declared a boolean variable at the top of a module, ready to act as a "switch" so that the loop can keep testing to see if the switch has changed, and therefore exit, but I can't see how I can run the loop as the workbook saves.
Any ideas?
Does anyone know if it's possible to use "ActiveWorkbook.Save" then have a loop running until the workbook's finished saving?
I'm trying to design a "Saving indicator" - a bit like a progress bar but with dots appearing in a line.
The code below works well. It's called from a userform (userform4).
On the userform are 3 labels.
One ("mess") contains the caption - either "Please wait - saving workbook", or "Workbook saved."
The other 2 are laid one on top of the other. Both have the same background colour as the userform. The bottom one contains a row of dots. As the loop progresses it moves the top one ("waiting") to the right and slowly reveals the line of dots.
When the loop's been through 20 iterations it re-sets everything and starts again.
At the moment it does this five times (the outer loop) then stops.
Code:
Sub clrout()
Dim i As Integer, i2 As Integer
With UserForm4
.mess.Caption = "Please wait - saving workbook"
.mess.Width = 174
.Label35.Left = .mess.Left + .mess.Width
.waiting.Left = .Label35.Left
End With
wb_saving = True
i = 0
i2 = 0
Do Until i2 = 5
Do Until i = 20
Start = Timer
Do Until Timer > Start + 0.15
Loop
UserForm4.waiting.Left = UserForm4.waiting.Left + 5
i = i + 1
DoEvents
Loop
UserForm4.waiting.Left = UserForm4.Label35.Left
i = 0
i2 = i2 + 1
DoEvents
Loop
UserForm4.mess.Caption = "Workbook saved"
End Sub
What I'm trying to achieve is to start this loop when I start saving the workbook (it's taking about 10 seconds to save at the moment, but this will increase as it gets bigger) and exit it when the save has finished.
I've already declared a boolean variable at the top of a module, ready to act as a "switch" so that the loop can keep testing to see if the switch has changed, and therefore exit, but I can't see how I can run the loop as the workbook saves.
Any ideas?