无法获取活动幻灯片的索引
Can't get index of active slide
我正在尝试获取活动幻灯片的索引并将其存储为整数,以便我可以调用函数并传入整数。
我遵循了一个在 MsgBox 中显示整数索引的代码,它运行良好。然而,当我尝试将索引简单地存储为整数时,没有任何反应(你为什么这样,VBA?)
此代码运行完美,只有 2 行,并显示索引的整数。
Sub SlideIDX()
MsgBox "The slide index of the current slide is:" & _
activePresentation.SlideShowWindow.View.Slide.slideIndex
End Sub
This code is almost identical but makes the foolish attempt of storing an integer, the most complicated of tasks.
Sub slidePassInTest()
Dim passInteger As Integer
Set passInteger = activePresentation.SlideShowWindow.View.Slide.slideIndex
MsgBox (passInteger)
End Sub
我也试过不使用 Set。
这个方法对我一直有效:
Sub SlideIDX()
Dim currentSlide As Slide
Dim slideIndex as Long
Set currentSlide = Application.ActiveWindow.View.Slide
slideIndex = currentSlide.SlideIndex
End Sub
我正在尝试获取活动幻灯片的索引并将其存储为整数,以便我可以调用函数并传入整数。
我遵循了一个在 MsgBox 中显示整数索引的代码,它运行良好。然而,当我尝试将索引简单地存储为整数时,没有任何反应(你为什么这样,VBA?)
此代码运行完美,只有 2 行,并显示索引的整数。
Sub SlideIDX()
MsgBox "The slide index of the current slide is:" & _
activePresentation.SlideShowWindow.View.Slide.slideIndex
End Sub
This code is almost identical but makes the foolish attempt of storing an integer, the most complicated of tasks.
Sub slidePassInTest()
Dim passInteger As Integer
Set passInteger = activePresentation.SlideShowWindow.View.Slide.slideIndex
MsgBox (passInteger)
End Sub
我也试过不使用 Set。
这个方法对我一直有效:
Sub SlideIDX()
Dim currentSlide As Slide
Dim slideIndex as Long
Set currentSlide = Application.ActiveWindow.View.Slide
slideIndex = currentSlide.SlideIndex
End Sub