无法获取活动幻灯片的索引

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

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

我遵循了一段在 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。

vba powerpoint
2个回答
1
投票

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

Sub SlideIDX()

Dim currentSlide As Slide

Dim slideIndex as Long

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

End Sub

0
投票

请帮助我@All。 这段代码没有用VBA写出来。

子幻灯片IDX3() 调暗当前幻灯片作为幻灯片 昏暗的幻灯片索引只要 设置 currentSlide = Application.ActiveWindow.View.Slide 幻灯片索引 = 当前幻灯片.幻灯片索引 MsgBox "当前幻灯片的幻灯片索引是:" &lideIndex 结束子

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