Excel VBA如何在每张幻灯片上重复代码以编辑第一个文本框?
我正在为Powerpoint编写VB代码。它从幻灯片上的第二个文本框中检索日期,并计算到该日期的天数。然后,计算的天数显示在第一个文本框中。虽然文本框的名称与第一张幻灯片的名称相同,但我无法让代码在第二张幻灯片中重复Excel VBA如何在每张幻灯片上重复代码以编辑第一个文本框?,excel,vba,loops,powerpoint,simpledateformat,Excel,Vba,Loops,Powerpoint,Simpledateformat,我正在为Powerpoint编写VB代码。它从幻灯片上的第二个文本框中检索日期,并计算到该日期的天数。然后,计算的天数显示在第一个文本框中。虽然文本框的名称与第一张幻灯片的名称相同,但我无法让代码在第二张幻灯片中重复 'Sets variables Dim Sdate As Long Dim thedate As Date Dim txt As Date Dim pptSlide3 As Slide Do For Each pptSlide3 In ActivePresentation.Sl
'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
”设置变量
长的
将日期变暗为日期
日期
将PPT滑块3调暗为滑块
做
对于ActivePresentation.Slides中的每个pptSlide3
设置sld=ActivePresentation.SlideShowWindow.View.Slide
'从相应的文本框中检索D-Day
TextBox2.Font.Size=36
thedate=TextBox2.Text
'计算从今天的日期到上述D日的时间量
Sdate=DateDiff(“d”,Now(),thedate)
'创建具有剩余天数值的文本框
TextBox1.Value=Sdate&“还有几天!”
TextBox1.Font.Size=36
“要在这里等5秒钟吗
'转到下一张幻灯片
带幻灯片窗口(1)。查看
如果sld.SlideIndex<4,则
.GotoSlide(sld.SlideIndex+1)
如果结束
如果sld.SlideIndex=4,则
.GotoSlide(1)
如果结束
以
下一篇PPT幻灯片3
环
试试这样的方法:
Do
For Each pptSlide3 In ActivePresentation.Slides
'Retrieves D-Day from corresponding text box
TextBox2.Font.Size = 36
thedate = pptSlide3.Shapes("TextBox2").OLEFormat.Object.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
pptSlide3.Shapes("TextBox1").OLEFormat.Object.Text = Sdate & " Days to go!"
TextBox1.Font.Size = 36
'Want it to wait 5 seconds here
' Goes to next slide
With SlideShowWindows(1).View
If pptSlide3.SlideIndex < 4 Then
.GotoSlide (pptSlide3.SlideIndex + 1)
End If
If pptSlide3.SlideIndex = 4 Then
.GotoSlide (1)
End If
End With
Next pptSlide3
Loop
Do
对于ActivePresentation.Slides中的每个pptSlide3
'从相应的文本框中检索D-Day
TextBox2.Font.Size=36
thedate=pptSlide3.Shapes(“TextBox2”).OLEFormat.Object.Text
'计算从今天的日期到上述D日的时间量
Sdate=DateDiff(“d”,Now(),thedate)
'创建具有剩余天数值的文本框
pptSlide3.Shapes(“TextBox1”).OLEFormat.Object.Text=Sdate&“还有几天!”
TextBox1.Font.Size=36
“要在这里等5秒钟吗
'转到下一张幻灯片
带幻灯片窗口(1)。查看
如果pptSlide3.SlideIndex<4,则
.GotoSlide(pptSlide3.SlideIndex+1)
如果结束
如果pptSlide3.SlideIndex=4,则
.GotoSlide(1)
如果结束
以
下一篇PPT幻灯片3
环
有效,谢谢!我得调查一下。。你有没有可能知道怎么延迟五秒钟?睡眠对我不起作用。谢谢,阿加尼使用了以下作为计时器Start=Timer
而Timer
做事件
Wed
只是为了填补一两个空白:当幻灯片上有ActiveX控件时,形状的OLEFormat.Object允许您访问从表单上的同一形状获得的相同属性。不幸的是,Intellisense没有提供帮助,但您可以右键单击形状并选择“属性”,以查看哪些属性可用以及它们的名称。