注意:你可以不懂VB编程语言直接使用,如果需要高级功能或者改进,需要懂得VB编程语言
1、打开Visual Basic Editor
打开编辑器:Tools > Macro > Visual Basic Editor
复制以下程序在编辑器里面
保存之后选择<关闭并返回powerpoint>
Sub AddProgressBar()
' Parameters to set
progressBarHeight = 3.5 ' height of the progress bar
FillColor = RGB(251, 0, 6) ' Fill color of the progress bar
LineColor = FillColor ' Line color of the progress bar
BackgroundColor = RGB(255, 255, 255) ' background color of the progress bar
fontColor = FillColor
startingSlideNo = 1
noFontSize = 13
showSlideNo = True ' Set this to False if you dont want to show total slide no
'Slider Making
On Error Resume Next
With ActivePresentation
sHeight = .PageSetup.SlideHeight - progressBarHeight
n = 0
j = 0
For i = 1 To .Slides.Count
If .Slides(i).SlideShowTransition.Hidden Then j = j + 1
Next i:
For i = startingSlideNo To .Slides.Count
.Slides(i).Shapes("progressBar").Delete
.Slides(i).Shapes("progressBarBackground").Delete
.Slides(i).Shapes("pageNumber").Delete
If .Slides(i).SlideShowTransition.Hidden = msoFalse Then
' Background setting
' Underscore used for continuation of line
Set sliderBack = .Slides(i).Shapes.AddShape( _
msoShapeRectangle, 0, _
sHeight, (.Slides.Count - j) _
* .PageSetup.SlideWidth _
/ (.Slides.Count - j), _
progressBarHeight)
With sliderBack
.Fill.ForeColor.RGB = BackgroundColor
.Line.ForeColor.RGB = BackgroundColor
.Name = "progressBarBackground"
End With
' Main Slider setting
Set slider = .Slides(i).Shapes.AddShape( _
msoShapeRectangle, 0, _
sHeight, (i - n) * _
.PageSetup.SlideWidth _
/ (.Slides.Count - j), _
progressBarHeight)
With slider
' enable this line to set theme color
'.Fill.ForeColor.RGB = ActivePresentation.SlideMaster.ColorScheme.Colors( _
ppFill).RGB
.Fill.ForeColor.RGB = FillColor
.Line.ForeColor.RGB = LineColor
.Name = "progressBar"
End With
Set pageNumber = .Slides(i).Shapes.AddTextbox( _
msoTextOrientationHorizontal, _
((.Slides.Count - j) * _
.PageSetup.SlideWidth / _
(.Slides.Count - j)) - 50, _
.PageSetup.SlideHeight - 23, 100, 10)
' Slide No
If showSlideNo = True Then
With pageNumber
.TextFrame.TextRange.Text = Str(i - n) & "/" & _
Str(ActivePresentation.Slides.Count - j)
With .TextFrame.TextRange.Font
.Bold = msoFalse
.Size = noFontSize
.Color = fontColor
End With
.Name = "pageNumber"
End With
End If
Else
n = n + 1
End If
Next i:
End With
End Sub
Sub RemoveProgressBar()
On Error Resume Next
With ActivePresentation
For i = 1 To .Slides.Count
.Slides(i).Shapes("progressBar").Delete
.Slides(i).Shapes("progressBarBackground").Delete
.Slides(i).Shapes("pageNumber").Delete
Next i:
End With
End Sub
2、添加
通过以上操作,增加了两个宏程序:1:AddProgressBar ; 2: RemoveProgressBar
添加进程条:Tools > Macro
在宏程序里面选择:AddProgressBar,然后点击运行
如果要取消,则同样操作,选择RemoveProgressBar。
3、保存
保存文档的时候,会推送警告,这是因为普通的ppt,或pptx与宏程序不兼容。
如果需要保存成宏程序兼容的版本,另存为ppsm文件。
参考:
http://people.virginia.edu/~me5vp/blog/2016/07/progressbar-in-powerpoint.html
https://gist.github.com/PiiXiieeS/7181980
网友评论