Question

How can I make a progress bar with PowerPoint VBA? It should be done as an animation on a slide.

Was it helpful?

Solution

Is this what you're looking for?

http://www.pptfaq.com/FAQ00597.htm

OTHER TIPS

This one will put the bar at the top and prevent it from appearing on the first slide (unlike the pptfaq script):

http://www.faronics.com/news/blog/how-to-add-a-progress-bar-to-powerpoint/

  1. In Power Point, go to Tools > Macro > Visual Basic Editor.

  2. In Office 2010 you might need to activate the Developer tab in order to get to the editor. The Mac version will take you there through Developer tab > Editor.

  3. Once you are in the editor, go Insert > Module.

Four. Paste the following code in this newly created module:

Sub Presentation_Progress_Marker() 
On Error Resume Next 
With ActivePresentation 
For N = 2 To .Slides.Count
.Slides(N).Shapes(“Progress_Marker”).Delete 
Set s = .Slides(N).Shapes.AddShape(msoShapeRectangle, 0, 0, N * .PageSetup.SlideWidth /.Slides.Count, 10) 
Call s.Fill.Solid
s.Fill.ForeColor.RGB = RGB(23, 55, 94) 
s.Line.Visible = False
s.Name = “Progress_Marker” Next N: End With End Sub

Five. Close the editor. Finally, run the macro: Tools>Macro>Macros and select—Presentation_Progress_Marker.

How about adding a progress bar control by Microsoft ?

Since PowerPoint is not a real-time application, you might not be able to see the progress bar moving if you make it with some shapes. Sometimes you might end up seeing the final result only - only full bar or even nothing at all). On the contrary, the progress bar control is more 'real-time' or more up-to-time.(I admit that it's a little classic design.)

Here's some steps for somebody:

  1. To add a progress bar control, first you need to add a UserForm in VBE(Alt-F11) Window. (Menu: Insert - UserForm)

  2. Right-click on the toolbox window that appears and choose additional control. Scroll down and check 'Microsoft Progress Bar Control, version x.0' (This control is provided by MSCOMCTL.OCX)

Click OK. Now you see the progress bar icon at the end of the tool list. Click it and draw a progress bar on UserForm1. Resize the UserForm1 window. The smaller, the better. You can change the title of the window from 'UserForm1' to 'Progressing...' or any message you like by changing the Caption value in the Property window.

  1. Add a Module and put some code like below.

Option Explicit
Sub MyJob()

'Show the Progress Bar window UserForm1.Show vbModeless 'vbModeless option should be added Dim i As Long, Total As Long Total = 200 Randomize For i = 1 To Total 'put some code here. Especially, some jobs that take some time. 'for example, add a rounded box with random color on slide #1 With ActivePresentation.Slides(1).Shapes.AddShape(msoShapeRoundedRectangle, i, i, 500, 200) .Name = "Shape_" & i .Fill.ForeColor.RGB = RGB(255 * Rnd, 255 * Rnd, 255 * Rnd) .Adjustments(1) = 0.5 .Line.Visible = msoFalse .TextFrame.TextRange = i End With 'Update the Progress bar UserForm1.ProgressBar1.Value = Int(i * 100 / Total) 'integer between 0 and 100. Otherwise, pops up an error UserForm1.Repaint 'refresh the Userform Next i 'close ProgressBar UserForm Unload UserForm1 End Sub

By default, the value of the progress bar should be an integer between 0 and 100. If it's '101', you get an error. So be careful.

  1. Also, you can change the shape of the progress bar by changing the property values. For example, the bar size, the location(Top, Left), the minimum value(0) or the maximum value(by default, it's 100. But you can change it to 50 or any value.).You can also change them programmatically.

The progress bar is somewhat old-fashioned, but useful for its faster(?) reaction than the user-created shape-type progress bar.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top