0

I'm making a loop presentation in PowerPoint and I need a countdown to a specific date.

When using the code below i get following error:

Run-time error '-2147024809 (80070057)': The specified value is out of range.

Sub Countdown()
Dim thedate As Date
Dim daycount As Long
Dim Icount As Integer
Icount = ActivePresentation.Slides(1).Shapes.Count - 1
thedate = "25/12/2013"
daycount = DateDiff("d", Now, thedate)
Select Case daycount
    Case Is > 1
        ActivePresentation.Slides(1).Shapes(Icount) _
        .TextFrame.TextRange = daycount & " Days to go!"
    Case Is = 1
        ActivePresentation.Slides(1).Shapes(Icount) _
        .TextFrame.TextRange = daycount & " Day to go!"
    Case Else
        ActivePresentation.Slides(1).Shapes(Icount) _
        .TextFrame.TextRange = "It's here!"
End Select
End Sub

Please help me!

4

2 回答 2

0

您需要哈希符号来分隔日期值

thedate = #12/25/2013#

它的顺序是 mm/dd/yyyy。

还要记住 VBA 集合从 1 开始索引,因此 Shapes(countOfShapes) 将是最后一个 Shape。

于 2013-07-16T13:40:37.630 回答
0

你的代码:

Icount = ActivePresentation.Slides(1).Shapes.Count - 1
.....
Select Case daycount
    Case Is > 1
        ActivePresentation.Slides(1).Shapes(Icount) _

如果幻灯片上只有一个形状,ICount 将为 0 ActivePresentation.Slides(1).Shapes(Icount) 将抛出错误

于 2013-07-16T14:10:06.083 回答