PowerPoint Progress Indicator: Revisit an Old Issue

D

david.f.jenkins

I've researched these fora, and am reconciled to the lack of
out-of-the-box PowerPoint functionality for showing a macro "progress"
indicator. Following suggestions found here, I've decided to use a
User Form to display progress messages - this is a simple approach that
will provide the functionality that I need.

However. (Isn't there always a "however"?)

I designed a form with but a single label, which I'll update
periodically. In my test case, I have a loop which runs 2 iterations,
and contains this code:

load MyForm
for i = 1 to 2

MyForm.Label1 = "Iteration " & str(i)
MyForm.show vbModeless

'do some stuff

next i

MyForm.Hide
MyForm.Label1 = "Finished"
MyForm.show vbModal
MyForm.Hide

I have these problems:

1. PPT whines that it can't change the form from modeless to modal. I
got around this by inserting the Hide before setting Label1 to
"Finished" at the end of the loop. Is this the best way to do this?

2. When I use the form as modeless, only the outline and title bar of
the form show; the body ("Iteration nn") is empty and shows a white
background instead of gray. This occurs even when each iteration of
the loop runs for a long time (minutes). I haven't a clue as to what
to do to get around this...

If I make the form Modal, then for each iteration of the loop I can see
an updated version of the form - black text on gray background.
However, I'm required (it's modal, remember) to close the dialog box
before processing of the next loop continues - not an acceptable
behavior for my real-life application.

Any pointers you all can provide to help me though this would be
appreciated - thanks!
 
S

Steve Rindsberg

I've researched these fora, and am reconciled to the lack of
out-of-the-box PowerPoint functionality for showing a macro "progress"
indicator. Following suggestions found here, I've decided to use a
User Form to display progress messages - this is a simple approach that
will provide the functionality that I need.

However. (Isn't there always a "however"?)

I designed a form with but a single label, which I'll update
periodically. In my test case, I have a loop which runs 2 iterations,
and contains this code:

load MyForm
for i = 1 to 2

MyForm.Label1 = "Iteration " & str(i)
MyForm.show vbModeless

'do some stuff

next i

MyForm.Hide
MyForm.Label1 = "Finished"
MyForm.show vbModal
MyForm.Hide

I have these problems:

1. PPT whines that it can't change the form from modeless to modal.

Accessing a control on the form loads and (I think) shows it. By the time you
ask it to show modeless, it's already live and on the air. Too late.

Set the label to "Iteration " in the form design first.
Then show the form modeless
Then change the label to "Iteration " & str(i)
2. When I use the form as modeless, only the outline and title bar of
the form show; the body ("Iteration nn") is empty and shows a white
background instead of gray.

Include a DoEvents line after any line of code that changes the form.
If I make the form Modal, then for each iteration of the loop I can see
an updated version of the form - black text on gray background.
However, I'm required (it's modal, remember) to close the dialog box
before processing of the next loop continues - not an acceptable
behavior for my real-life application.

Right, a modal form won't do you much good here (and note that Office 97
doesn't permit modeless forms, so you may want to surround any code that
launches your progress meter with a text for PPT version 9 or higher.

Last time I cobbled one of these up, I wrote a sub something like this (dredged
out of my unreliable memory but it should give you the general idea)

Sub ProgressGauge(strCommand)

' if this is PPT97, do nothing at all
If int(val(Application.Version)) < 9 then
exit sub
End if

' So what's he want us to do? strCommand tells all:
Select Case ucase(strCommand )
Case is = "SHOW"
show the form
Case is = "HIDE"
hide and unload the form
case else
update the form with strCommand
you can pass other params instead
End Select



That way your main code can just do:

ProgressGauge("show")
Do while processing
ProgressGauge(cstr(ItemCount))
do some stuff
Loop
ProgressGauge("hide")

No need to test for PPT version with each iteration or anything.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top