如何在 powerpoint VBA 中以给定的 time/time 间隔关闭幻灯片视图?
How to close out of slideshow view at a given time/time interval in powerpoint VBA?
我最近开始 VBA 并正在尝试创建一个项目,该项目将打开一个 powerpoint 文件 (compute_dashboard.pptx) 并将其放在幻灯片视图中。它会遍历幻灯片并循环,直到达到特定的时间范围;在下面的这段代码中,它应该在 10:10:00 AM - 10:10:10 AM 退出并退出 powerpoint。我有两个不同的实现,每个都有自己的问题,如果你能找到一种方法来纠正它们中的任何一个,那就太好了。
在我的第一个实现中,它会打开文件,然后在时钟达到该时间范围之前 powerpoint 不会响应,然后它会正常退出应用程序。所以主要问题是我根本看不到幻灯片运行。
Sub OpenFile()
Set pptApp = CreateObject("PowerPoint.Application")
pptApp.Visible = True
Set pptPres = pptApp.Presentations.Open("Compute_Dashboard.pptx")
ActivePresentation.SlideShowSettings.Run
Dim b As Boolean
b = True
While b = True
If Time() > TimeValue("10:10:00") And Time() < TimeValue("10:10:10") Then
b = False
ActivePresentation.SlideShowWindow.view.Exit
Application.Quit
End If
With ActivePresentation.Slides(1).SlideShowTransition
.AdvanceOnTime = msoTrue
.AdvanceTime = 3
End With
Wend
在第二次实施中,它打开了文件并且幻灯片放映正确循环,但是我无法让幻灯片放映和 powerpoint 在我的时间范围内退出。
Sub OpenFile()
Set pptApp = CreateObject("PowerPoint.Application")
pptApp.Visible = True
Set pptPres = pptApp.Presentations.Open("Compute_Dashboard.pptx")
ActivePresentation.SlideShowSettings.Run
For Each s In ActivePresentation.Slides
With s.SlideShowTransition
.AdvanceOnTime = msoTrue
.AdvanceTime = 3
If Time() > TimeValue("10:10:00") And Time() < TimeValue("10:10:10") Then
ActivePresentation.SlideShowWindow.view.Exit
Application.Quit
End If
End With
Next
试试这个
Sub OpenFile()
Set pptApp = CreateObject("PowerPoint.Application")
pptApp.Visible = True
Set pptPres = pptApp.Presentations.Open("Compute_Dashboard.pptx")
ActivePresentation.SlideShowSettings.Run
For Each s In ActivePresentation.Slides
With s.SlideShowTransition
.AdvanceOnTime = msoTrue
.AdvanceTime = 3
End With
Next s
Dim b As Boolean
b = True
While b = True
If Time() > TimeValue("10:10:00") And Time() < TimeValue("10:10:10") Then
b = False
ActivePresentation.SlideShowWindow.view.Exit
Application.Quit
End If
Wend
我不能 100% 确定您的意图 - 我猜您只是想将每张幻灯片的推进时间设置为 3 秒并在特定时间退出。
设置幻灯片前进时间并不是触发幻灯片前进。它只是为该幻灯片设置 属性 - 3 秒后前进。
由于它在程序运行时为所有幻灯片设置这些属性,因此它会在程序运行时有效地检查 QUIT 要求,因此永远不会退出。
我最近开始 VBA 并正在尝试创建一个项目,该项目将打开一个 powerpoint 文件 (compute_dashboard.pptx) 并将其放在幻灯片视图中。它会遍历幻灯片并循环,直到达到特定的时间范围;在下面的这段代码中,它应该在 10:10:00 AM - 10:10:10 AM 退出并退出 powerpoint。我有两个不同的实现,每个都有自己的问题,如果你能找到一种方法来纠正它们中的任何一个,那就太好了。
在我的第一个实现中,它会打开文件,然后在时钟达到该时间范围之前 powerpoint 不会响应,然后它会正常退出应用程序。所以主要问题是我根本看不到幻灯片运行。
Sub OpenFile()
Set pptApp = CreateObject("PowerPoint.Application")
pptApp.Visible = True
Set pptPres = pptApp.Presentations.Open("Compute_Dashboard.pptx")
ActivePresentation.SlideShowSettings.Run
Dim b As Boolean
b = True
While b = True
If Time() > TimeValue("10:10:00") And Time() < TimeValue("10:10:10") Then
b = False
ActivePresentation.SlideShowWindow.view.Exit
Application.Quit
End If
With ActivePresentation.Slides(1).SlideShowTransition
.AdvanceOnTime = msoTrue
.AdvanceTime = 3
End With
Wend
在第二次实施中,它打开了文件并且幻灯片放映正确循环,但是我无法让幻灯片放映和 powerpoint 在我的时间范围内退出。
Sub OpenFile()
Set pptApp = CreateObject("PowerPoint.Application")
pptApp.Visible = True
Set pptPres = pptApp.Presentations.Open("Compute_Dashboard.pptx")
ActivePresentation.SlideShowSettings.Run
For Each s In ActivePresentation.Slides
With s.SlideShowTransition
.AdvanceOnTime = msoTrue
.AdvanceTime = 3
If Time() > TimeValue("10:10:00") And Time() < TimeValue("10:10:10") Then
ActivePresentation.SlideShowWindow.view.Exit
Application.Quit
End If
End With
Next
试试这个
Sub OpenFile()
Set pptApp = CreateObject("PowerPoint.Application")
pptApp.Visible = True
Set pptPres = pptApp.Presentations.Open("Compute_Dashboard.pptx")
ActivePresentation.SlideShowSettings.Run
For Each s In ActivePresentation.Slides
With s.SlideShowTransition
.AdvanceOnTime = msoTrue
.AdvanceTime = 3
End With
Next s
Dim b As Boolean
b = True
While b = True
If Time() > TimeValue("10:10:00") And Time() < TimeValue("10:10:10") Then
b = False
ActivePresentation.SlideShowWindow.view.Exit
Application.Quit
End If
Wend
我不能 100% 确定您的意图 - 我猜您只是想将每张幻灯片的推进时间设置为 3 秒并在特定时间退出。
设置幻灯片前进时间并不是触发幻灯片前进。它只是为该幻灯片设置 属性 - 3 秒后前进。
由于它在程序运行时为所有幻灯片设置这些属性,因此它会在程序运行时有效地检查 QUIT 要求,因此永远不会退出。