获取活动幻灯片的索引

问题描述 投票:0回答:1

我正在尝试获取活动幻灯片的索引并将其存储为整数,以便我可以调用函数并传入整数。

我有代码显示 MsgBox 中整数的索引。然而,当我尝试将索引存储为整数时,什么也没有发生。

此代码显示索引的整数。

Sub SlideIDX()
MsgBox "The slide index of the current slide is:" & _
  activePresentation.SlideShowWindow.View.Slide.slideIndex
End Sub

此代码尝试存储整数。

Sub slidePassInTest()
Dim passInteger As Integer
Set passInteger = activePresentation.SlideShowWindow.View.Slide.slideIndex
MsgBox (passInteger)
End Sub

我也尝试过不使用Set。

vba powerpoint
1个回答
1
投票

这个方法对我来说总是有效:

Sub SlideIDX()

Dim currentSlide As Slide

Dim slideIndex as Long

Set currentSlide = Application.ActiveWindow.View.Slide
slideIndex = currentSlide.SlideIndex

End Sub
© www.soinside.com 2019 - 2024. All rights reserved.