2012-09-10 103 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

相關問題