Progress Bar in PPT - vba

  • Thread starter Thread starter JEG
  • Start date Start date
J

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
 
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?
 
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?
 
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)
 
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
 
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!
 
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.
 
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
 
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.
 
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.
 
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.

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.
 
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
 
Back
Top