我有一个需要使用的按钮宏(如下)。我想要做的是将lngCurr
布局“节标题”的值更改为该值,并使宏运行时,用户返回到该特定布局的幻灯片的最后一个实例。
Dim lngCurr As Long lngCurr = SlideShowWindows(1).View.CurrentShowPosition SlideShowWindows(1).View.GotoSlide (lngCurr - 1), msoTrue
答案1
这是一个函数,它返回具有指定布局的最后一张幻灯片的幻灯片索引。加上您得到的结果,应该可以帮您找到它。
Sub Test()
MsgBox LastSlideWithLayout("Section header")
End Sub
Function LastSlideWithLayout(sLayoutName As String) As Long
Dim oSl As Slide
Dim x As Long
For x = ActivePresentation.Slides.Count To 1 Step -1
Set oSl = ActivePresentation.Slides(x)
If UCase(oSl.CustomLayout.Name) = UCase(sLayoutName) Then
LastSlideWithLayout = x
Exit Function
End If
Next
' return 0 to indicate that no slides with this layout were found
LastSlideWithLayout = 0
End Function