Microsoft Office Tutorials and References
In Depth Information
Displaying a Progress Indicator
Modifying your procedure for a progress indicator with a MultiPage control
You need to modify the procedure that is executed when the user clicks the OK button — the
Click event-handler procedure for the button named OKButton_Click . First, insert the
following statement at the top of your procedure:
MultiPage1.Value = 1
This statement activates Page2 of the MultiPage control (the page that displays the progress
indicator).
In the next step, you’re pretty much on your own. You need to write code to calculate the
percent completed and assign this value to a variable named PctDone . Most likely, this calculation
will be performed inside of a loop. Then insert the following statement, which will update the
progress indicator:
Call UpdateProgress(PctDone)
How a progress indicator with a Multipage control works
This technique is very straightforward and, as you’ve seen, it involves only one UserForm. The
code switches pages of the MultiPage control and converts your normal dialog box into a
progress indicator. Because the MultiPage tabs are hidden, it doesn’t even resemble a
MultiPage control.
Showing a progress indicator without using a MultiPage control
The example in this section is similar to the example in the preceding section. However, this
technique is simpler because it doesn’t use a MultiPage control. Rather, the progress indicator is
stored at the bottom of the UserForm — but the UserForm’s height is reduced so that the
progress indicator controls aren’t visible. When it’s time to display the progress indicator, the
UserForm’s height is increased, which makes the progress indicator visible.
The companion CD-ROM contains an example that demonstrates this technique. The file
is named progress indicator3.xlsm .
Figure 15-7 shows the UserForm in the VBE. The Height property of the UserForm is 172 .
However, before the UserForm is displayed, VBA code changes the Height to 124 (which
means the progress indicator controls aren’t visible to the user). When the user clicks OK, VBA
code changes the Height property to 172 with the following statement:
Me.Height = 172
 
Search JabSto ::




Custom Search