|
下面代码要实现的目标是:
在幻灯片放映模式下,母版中是否有一个叫做“进度条”的图形,没有就创建一个;有的话,就对其进行相应的操作,代码如下。
问题是:
1、有的话可以操作;
2、没有的话却不能创建。
Sub 幻灯片进度条()
'颜色1 = Array(vbRed, vbBlack, vbGreen, vbYellow, vbMagenta, vbBlue, vbCyan)
'颜色2 = Array(vbBlack, vbGreen, vbYellow, vbMagenta, vbBlue, vbCyan, vbRed)
'j = i Mod 7 + 1
Randomize
n = ActivePresentation.Slides.Count
i = ActivePresentation.SlideShowWindow.View.CurrentShowPosition
SlideMaster.Label1.Caption = "当 前" & vbCrLf & IIf(i = n, "结 束", i & "/" & n)
w = ActivePresentation.PageSetup.SlideWidth - 80
t = ActivePresentation.PageSetup.SlideHeight - 20
If ActivePresentation.SlideMaster.Shapes("进度条") Is Nothing Then
With ActivePresentation.SlideMaster.Shapes.AddShape(1, 72, t - 10, w * i / n, 30)
.Name = "进度条"
.Fill.BackColor.RGB = RGB(Int(255 * Rnd) + 1, Int(255 * Rnd) + 1, Int(255 * Rnd) + 1)
With .TextFrame.TextRange
.Text = Format(i / n, "0%")
.ParagraphFormat.Alignment = ppAlignRight
End With
.Fill.ForeColor.RGB = RGB(Int(255 * Rnd) + 1, Int(255 * Rnd) + 1, Int(255 * Rnd) + 1)
End With
Else
With ActivePresentation.SlideMaster.Shapes("进度条")
.Width = w * i / n
.Fill.BackColor.RGB = RGB(Int(255 * Rnd) + 1, Int(255 * Rnd) + 1, Int(255 * Rnd) + 1)
With .TextFrame.TextRange
.Text = Format(i / n, "0%")
.ParagraphFormat.Alignment = ppAlignRight
End With
.Fill.ForeColor.RGB = RGB(Int(255 * Rnd) + 1, Int(255 * Rnd) + 1, Int(255 * Rnd) + 1)
End With
End If
If i = n Then CreateObject("sapi.spvoice").speak "this is over!"
End Sub
该怎样修改才能创建这个图形?
都是优化惹的祸.zip
(43.47 KB, 下载次数: 10)
|
|