Discussion:
Progress Bar in PPT - vba
(too old to reply)
JEG
2005-04-28 16:41:25 UTC
Permalink
Is there a way to do a progress bar or status bar in PPT using VBA? I have
a slide where users can print files and some of the files they select are
actually made up of several documents and it may take a while to send to
the printer. Can I have a message box with a status bar or something
simliar?

Thanks!
Jackie
Austin Myers
2005-04-28 16:43:56 UTC
Permalink
Sure can, there are a couple of them present as controls you can use via
VBA.
Post by JEG
Is there a way to do a progress bar or status bar in PPT using VBA? I have
a slide where users can print files and some of the files they select are
actually made up of several documents and it may take a while to send to
the printer. Can I have a message box with a status bar or something
simliar?
Thanks!
Jackie
JEG
2005-04-28 17:13:00 UTC
Permalink
I don't see them as controls in my vba. I see one called DSSStatusBar
Class but when I try to insert it on my slide, I get an error message
saying, "Could Not Access System Registry." I'm looking under More
Controls -- is it called something I wouldn't recognize as a Status Bar?
JEG
2005-04-28 17:19:19 UTC
Permalink
I don't see them as controls in my vba. I see one called DSSStatusBar
Class but when I try to insert it on my slide, I get an error message
saying, "Could Not Access System Registry." I'm looking under More
Controls -- is it called something I wouldn't recognize as a Status Bar?
JEG
2005-04-28 17:31:29 UTC
Permalink
I see one now -- Microsoft Progress Bar. I'm a little confused as to how
to use it. When I put it on the slide, it's just blue "progress" boxes.
Is there a way to put this on a message box?

Thanks again!
(sorry about the double post -- don't know what happened)
Austin Myers
2005-04-28 18:49:45 UTC
Permalink
Use of a progress bar can be a good deal of work. (Coding) It all depends
upon how you want to use it and what you tie it too. I'd suggest taking a
look at the MS knowledge base to get started.

Austin Myers
MS PowerPoint MVP Team
Post by JEG
I see one now -- Microsoft Progress Bar. I'm a little confused as to how
to use it. When I put it on the slide, it's just blue "progress" boxes.
Is there a way to put this on a message box?
Thanks again!
(sorry about the double post -- don't know what happened)
TAJ Simmons
2005-04-28 19:22:05 UTC
Permalink
JEG,

see this progress add in
http://www.indezine.com/addin/thermometer/

Cheers
TAJ Simmons
microsoft powerpoint mvp

awesome - powerpoint backgrounds,
http://www.powerpointbackgrounds.com
free powerpoint templates, tutorials, hints and tips etc
Post by Austin Myers
Use of a progress bar can be a good deal of work. (Coding) It all depends
upon how you want to use it and what you tie it too. I'd suggest taking a
look at the MS knowledge base to get started.
Austin Myers
MS PowerPoint MVP Team
Post by JEG
I see one now -- Microsoft Progress Bar. I'm a little confused as to how
to use it. When I put it on the slide, it's just blue "progress" boxes.
Is there a way to put this on a message box?
Thanks again!
(sorry about the double post -- don't know what happened)
JEG
2005-04-28 19:53:05 UTC
Permalink
Thanks so much for your replies. I looked at the thermometer add-in -- I
just need my progress bar to do something different rather than showing
the progress of a presentation.

Ideally would like the progress bar to be used to show the user what
percentage of files had been sent to the printer. With one "print" button,
about 15 files are sent to the printer (via ShellExecute because they are
pdfs). I wanted the progress bar to correlate to the number of files sent
to the printer. But if it's easier (and I am new to coding) I could do it
just showing passage of time. I have set up a timer to pause for a few
minutes after sending the files to the printer, because then it's going to
terminate Acrobat and I need to make sure it didn't get closed before the
files were sent to print. Would that be an easier coding situation for a
newbie?

Thanks!
Steve Rindsberg
2005-04-28 21:35:15 UTC
Permalink
Post by JEG
Is there a way to do a progress bar or status bar in PPT using VBA? I have
a slide where users can print files and some of the files they select are
actually made up of several documents and it may take a while to send to
the printer. Can I have a message box with a status bar or something
simliar?
Any sort of progress bar, whether a control or one you create yourself using a
userform, needs input. It needs to be updated periodically with the percent
complete info you want to display. Do you have a way of grabbing that info?

One sillysimple way of doing a progress bar is to create a user form with a
label on it. The label's b/g is set to a color, the width of the label starts
at 0. As the process progresses, you set the width of the label to ever larger
values.

-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
JEG
2005-04-28 23:01:58 UTC
Permalink
Unfortunately I don't know how to grab the information I'm trying to
display -- the percent of files that have been sent to the printer by
ShellExecute (like 1 of 15, 2 of 15, etc). So what I've done now is ugly
but maybe someone has an improvement to offer. I just made my progress
bar in time increments so at least my program has time to pause before the
"Quit Acrobat" procedure is triggered and the user will know something is
happening. Here's what I have so far (there must be a better way!):
Dim PauseTime, Start
user_print = MsgBox("The documents have been sent to the default
printer.", vbMsgBoxSetForeground)
If (user_print = vbOK) Then
UserForm1.Show
ProgressBar1.Value = 0
PauseTime = 5 ' Set duration.
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
DoEvents ' Yield to other processes.
Loop
ProgressBar1.Value = 10
PauseTime = 5 ' Set duration.
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
DoEvents ' Yield to other processes.
Loop
ProgressBar1.Value = 20
PauseTime = 5 ' Set duration.
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
DoEvents ' Yield to other processes.
Loop
ProgressBar1.Value = 30
PauseTime = 5 ' Set duration.
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
DoEvents ' Yield to other processes.
Loop
('this really continues on to ProgressBar is 100)
Else
End
End If
Steve Rindsberg
2005-04-29 02:00:40 UTC
Permalink
It seems that this gives you a progress bar that runs for an arbitrary amount
of time, but does it have any relationship to the actual time needed to
complete the task?

Can you ShellExecute the files to print them one at a time?
If so, you know the number of files to be printed and which one you're
currently sending; there's your progress meter value. It should be 20% of the
way across when you start printing file 2 of 5.
Post by JEG
Unfortunately I don't know how to grab the information I'm trying to
display -- the percent of files that have been sent to the printer by
ShellExecute (like 1 of 15, 2 of 15, etc). So what I've done now is ugly
but maybe someone has an improvement to offer. I just made my progress
bar in time increments so at least my program has time to pause before the
"Quit Acrobat" procedure is triggered and the user will know something is
Dim PauseTime, Start
user_print = MsgBox("The documents have been sent to the default
printer.", vbMsgBoxSetForeground)
If (user_print = vbOK) Then
UserForm1.Show
ProgressBar1.Value = 0
PauseTime = 5 ' Set duration.
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
DoEvents ' Yield to other processes.
Loop
ProgressBar1.Value = 10
PauseTime = 5 ' Set duration.
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
DoEvents ' Yield to other processes.
Loop
ProgressBar1.Value = 20
PauseTime = 5 ' Set duration.
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
DoEvents ' Yield to other processes.
Loop
ProgressBar1.Value = 30
PauseTime = 5 ' Set duration.
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
DoEvents ' Yield to other processes.
Loop
('this really continues on to ProgressBar is 100)
Else
End
End If
-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
JEG
2005-04-29 06:07:01 UTC
Permalink
Yes that's exactly what I should do, but I don't know how to tell the
progress bar how many files have been sent to the printer. I am
ShellExecuting them one at a time like this:

Private Sub Command1_Click()
If OptionButton1.Value Then
call shelldoc("c:\file1.pdf")
call shelldoc("c:\file2.pdf")
call shelldoc("c:\file3.pdf")
etc.
Steve Rindsberg
2005-04-29 16:23:13 UTC
Permalink
Post by JEG
Yes that's exactly what I should do, but I don't know how to tell the
progress bar how many files have been sent to the printer. I am
Private Sub Command1_Click()
If OptionButton1.Value Then
call shelldoc("c:\file1.pdf")
call shelldoc("c:\file2.pdf")
call shelldoc("c:\file3.pdf")
etc.
All you can really control is when you send the files; how fast they print
depends on a lot of stuff that you can't easily get any feedback on.

But your list of files is coming from somewhere. Is it hardcoded or ...?

Given the list of files you intend to send, you know how many there are and can
keep count of which file you're sending at any given moment - use that to
update the progress dialog.



-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
awv
2005-05-26 19:45:27 UTC
Permalink
I hope that the code below helps. You will need to know a bit of info before
using it though. I hopefully have given you everything you need, but if not
it should be easy enough to modify.

Needed Info:
Number of files to be printed.
Progress Bar control on UserForm1 (the progress bar you already have).

Code:
Private Sub CommandButton1_Click()
Dim strFile As String 'Name of file
Dim sngStart As Single
Dim sngPauseTime As Single
Dim i As Integer
On Error GoTo err_CommandButton1_Click

UserForm1.Show True
UserForm1.ProgressBar1.Max = 15 'Hard coded to make it work.
sngPauseTime = 5 'Pause time is the same for everything so take it
out of the loops _
and only run it once


'If you can use a for loop, you don't need to have the timer except to
wait for the ShellExecute.
For i = 0 To 15 'Hard coded number to make work could be variable taken
from number to be printed.
'Shell strFile, vbHide 'Place the shellExecute function here to
printout your files one at a time.

sngStart = Timer
Do While Timer < sngStart + sngPauseTime
DoEvents 'This can go here or after 'Loop'
Loop
UserForm1.ProgressBar1.Value = i 'Sets the value equal to the
file you have just printed.
'DoEvents
Next i
Unload UserForm1 'Close modal form and return to program

Exit_CommandButton1_Click:
Exit Sub
err_CommandButton1_Click:
Resume Exit_CommandButton1_Click
End Sub



'Place code in your click event.

ProgressBar1.max = 15 'number of files to be printed can be set to a
variable, etc.



I hope that this is helpful to you. The primary thing is the use of the max
property of the progressBar.

Good Luck
Post by JEG
Unfortunately I don't know how to grab the information I'm trying to
display -- the percent of files that have been sent to the printer by
ShellExecute (like 1 of 15, 2 of 15, etc). So what I've done now is ugly
but maybe someone has an improvement to offer. I just made my progress
bar in time increments so at least my program has time to pause before the
"Quit Acrobat" procedure is triggered and the user will know something is
Dim PauseTime, Start
user_print = MsgBox("The documents have been sent to the default
printer.", vbMsgBoxSetForeground)
If (user_print = vbOK) Then
UserForm1.Show
ProgressBar1.Value = 0
PauseTime = 5 ' Set duration.
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
DoEvents ' Yield to other processes.
Loop
ProgressBar1.Value = 10
PauseTime = 5 ' Set duration.
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
DoEvents ' Yield to other processes.
Loop
ProgressBar1.Value = 20
PauseTime = 5 ' Set duration.
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
DoEvents ' Yield to other processes.
Loop
ProgressBar1.Value = 30
PauseTime = 5 ' Set duration.
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
DoEvents ' Yield to other processes.
Loop
('this really continues on to ProgressBar is 100)
Else
End
End If
Loading...