VBA Excel 到 Powerpoint,向前移动 1 张幻灯片
VBA Excel to Powerpoint, move 1 slide forward
我正在尝试创建一个打开 pp 的宏,然后向前移动一张幻灯片并将其设为我的活动幻灯片。
我觉得有一个简单的解决方案,但我似乎找不到代码让我前进一张幻灯片。
到目前为止我有
Private Sub OpenPowerpoint()
' Opens Presentation.pptx
Dim PPT As PowerPoint.Application
Set PPT = New PowerPoint.Application
PPT.Visible = True
PPT.Presentations.Open Filename:="C:\Users\Person\Desktop\Test\Template.pptx"
End Sub
在第一张幻灯片上打开我的 pp。
Window.View.GoToSlide
会让您转到特定的幻灯片编号。
Window.View.Slide.SlideIndex
会告诉您当前所在的幻灯片编号。
Presentation.Slides.Count
会告诉您演示文稿中有多少张幻灯片,这样您就不会试图越过结尾。
放在一起:
Private Sub OpenPowerpoint()
' Opens Presentation.pptx
Dim PPT As PowerPoint.Application, PPP As PowerPoint.Presentation, PPW As Object
Set PPT = New PowerPoint.Application
PPT.Visible = True
Set PPP = PPT.Presentations.Open(FileName:="C:\Users\Person\Desktop\Test\Template.pptx")
Set PPW = PPP.Windows(PPP.Windows.Count)
'If there are more slides, go to the next one
If PPW.View.Slide.SlideIndex < PPP.Slides.Count Then PPW.View.GotoSlide PPW.View.SlideIndex + 1
End Sub
你就快完成了 - 使用你的代码,只需添加 PPT.ActivePresentation.Slides(2).Select
:
Private Sub OpenPowerpoint()
Dim PPT As PowerPoint.Application
Set PPT = New PowerPoint.Application
PPT.Visible = True
PPT.Presentations.Open Filename:="C:\Users\Person\Desktop\Test\Template.pptx"
PPT.ActivePresentation.Slides(2).Select
End Sub
我正在尝试创建一个打开 pp 的宏,然后向前移动一张幻灯片并将其设为我的活动幻灯片。 我觉得有一个简单的解决方案,但我似乎找不到代码让我前进一张幻灯片。 到目前为止我有
Private Sub OpenPowerpoint()
' Opens Presentation.pptx
Dim PPT As PowerPoint.Application
Set PPT = New PowerPoint.Application
PPT.Visible = True
PPT.Presentations.Open Filename:="C:\Users\Person\Desktop\Test\Template.pptx"
End Sub
在第一张幻灯片上打开我的 pp。
Window.View.GoToSlide
会让您转到特定的幻灯片编号。
Window.View.Slide.SlideIndex
会告诉您当前所在的幻灯片编号。
Presentation.Slides.Count
会告诉您演示文稿中有多少张幻灯片,这样您就不会试图越过结尾。
放在一起:
Private Sub OpenPowerpoint()
' Opens Presentation.pptx
Dim PPT As PowerPoint.Application, PPP As PowerPoint.Presentation, PPW As Object
Set PPT = New PowerPoint.Application
PPT.Visible = True
Set PPP = PPT.Presentations.Open(FileName:="C:\Users\Person\Desktop\Test\Template.pptx")
Set PPW = PPP.Windows(PPP.Windows.Count)
'If there are more slides, go to the next one
If PPW.View.Slide.SlideIndex < PPP.Slides.Count Then PPW.View.GotoSlide PPW.View.SlideIndex + 1
End Sub
你就快完成了 - 使用你的代码,只需添加 PPT.ActivePresentation.Slides(2).Select
:
Private Sub OpenPowerpoint()
Dim PPT As PowerPoint.Application
Set PPT = New PowerPoint.Application
PPT.Visible = True
PPT.Presentations.Open Filename:="C:\Users\Person\Desktop\Test\Template.pptx"
PPT.ActivePresentation.Slides(2).Select
End Sub