我正在尝试获取活动幻灯片的索引并将其存储为整数,以便可以调用函数并传入整数。
我遵循了一个在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。
答案 0 :(得分:0)
此方法始终对我有效:
Sub SlideIDX()
Dim currentSlide As Slide
Dim slideIndex as Long
Set currentSlide = Application.ActiveWindow.View.Slide
slideIndex = currentSlide.SlideIndex
End Sub