2012-09-10 107 views
1

我会如何实现这一目标?因为我经常添加和删除幻灯片,所以我需要使用代码来了解我来自哪个幻灯片,而不仅仅是设置幻灯片。VBA PowerPoint - 回到幻灯片我来自

+0

你是什么意思'回到我来自幻灯片'。您是通过代码进行移动还是您的意思是每次手动删除或插入您想要返回到之前选定幻灯片的幻灯片?如果您删除多幻灯片删除中的上一张幻灯片,该怎么办? – brettdj

+0

我想通了,但我感觉与该代码来限制。 – dennis96411

回答

4
SlideShowWindows(1).View.GotoSlide(SlideShowWindows(1).View.LastSlideViewed.SlideIndex) 
+0

这比我使用的LOL简单得多! – dennis96411

0

我想通了。从浏览网页和一点思维的一些帮助,我本想出了:

对于存储,除了需要你回去到另一张幻灯片的幻灯片当前幻灯片编号,我做了一个模块:

Public CurrentSlide As Long, PreviousSlide As Long 

Public Sub GoToPreviousSlide() 
SlideShowWindows(1).View.GoToSlide (PreviousSlide) 
End Sub 

Public Sub StoreCurrentSlide() 
CurrentSlide = ActivePresentation.SlideShowWindow.View.Slide.SlideIndex 
If CurrentSlide <> 14 Then 
'Execute only if the current slide is not a slide that uses this function (because if you store the current slide while in a slide that requires you to go back to another slide, it will overwrite the PurrentSlide value and render this useless). Add more slide numbers to the If statement as you need them. 
PreviousSlide = CurrentSlide 
Call GoToPreviousSlide 
End If 
End Sub 

当然我必须确保我打电话StoreCurrentSlide每一个幻灯片的变化,我做了另一个模块自动执行此时间:

Public Sub OnSlideShowPageChange() 
StoreCurrentSlide 
End Sub 

现在,我可以在任何地方使用一个按钮并返回到以前的幻灯片使用:

Private Sub OK_Click() 
GoToPreviousSlide 
End Sub 
0

如果您使用的是按钮无论如何,为什么不使用PPT的操作设置;分配先前观看的幻灯片的动作设置。单击该按钮将使观众回到当前幻灯片之前他们正在查看的任何幻灯片。

不需要VBA。

+1

我对操作设置有不好的经验,但那是在Office 2003中。它会在幻灯片之前,而不是我从幻灯片来的幻灯片。比如说,如果我从第2张幻灯片跳到第5张幻灯片,并且想要返回,则动作设置会将我带到4。 – dennis96411

相关问题