【发布时间】:2016-06-06 20:42:06
【问题描述】:
我正在为 Powerpoint 编写一个 VB 代码。它从幻灯片上的 SECOND 文本框中检索日期并计算距离该日期的天数。然后计算的天数显示在第一个文本框中。尽管文本框的名称与第一张幻灯片相同,但我无法为第二张幻灯片重复代码。
'Sets variables
Dim Sdate As Long
Dim thedate As Date
Dim txt As Date
Dim pptSlide3 As Slide
Do
For Each pptSlide3 In ActivePresentation.Slides
Set sld = ActivePresentation.SlideShowWindow.View.Slide
'Retrieves D-Day from corresponding text box
TextBox2.Font.Size = 36
thedate = TextBox2.Text
'Calculates the amount of time from today's date until D-day above
Sdate = DateDiff("d", Now(), thedate)
'Creates textbox with the value of how many days are left
TextBox1.Value = Sdate & " Days to go!"
TextBox1.Font.Size = 36
'Want it to wait 5 seconds here
' Goes to next slide
With SlideShowWindows(1).View
If sld.SlideIndex < 4 Then
.GotoSlide (sld.SlideIndex + 1)
End If
If sld.SlideIndex = 4 Then
.GotoSlide (1)
End If
End With
Next pptSlide3
Loop
【问题讨论】:
标签: excel vba loops powerpoint simpledateformat