我正在尝试获取活动幻灯片的索引并将其存储为整数,以便我可以调用函数并传入整数。
我遵循了一个在 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
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句