2014-01-06 98 views
1

我有一個宏應該使頁面上的每個形狀可見(我有其他宏使它們不可見)。下面是代碼:PowerPoint 2013宏運行緩慢(重繪問題?)

Dim Slide As Integer 
Slide = SSW.View.CurrentShowPosition 
If Slide = 1 Then 
    For Each shp In ActivePresentation.Slides(2).Shapes 
     shp.Visible = True 
    Next shp 
End if 

這個宏需要永遠運行。我懷疑這是因爲每次形狀變得可見時都會重新繪製屏幕。

這不是必需的,事實上,當運行這個宏時它甚至沒有在屏幕上顯示幻燈片(它在幻燈片1上運行,但是使幻燈片2上的形狀可見)。有什麼方法可以讓這個運行更快嗎?禁用屏幕刷新或什麼?

我試過Shyam的http://www.vbaexpress.com/forum/showthread.php?33671-Solved-PP2010-ScreenUpdating-False解決方案,但它不起作用。他唯一的上升到2010年,我使用2013年。

回答

0

你的代碼不工作如圖所示。我改成了這一點,這工作幾乎立即與175點的形狀幻燈片:

' Put this at the top of every module; builds character, keeps you out of trouble 
Option Explicit 

Sub ThisWorks() 

' Always dim ALL variables 
Dim Slide As Long ' SlideIndex is a Long, not an Integer 
Dim oSh As Shape 

' Replaced your SSW with this: 
Slide = SlideShowWindows(1).View.CurrentShowPosition 
If Slide = 1 Then 
    For Each oSh In ActivePresentation.Slides(2).Shapes 
     ' I was toggling them back and forth as a test 
     ' oSh.Visible = Not oSh.Visible 
     oSh.Visible = True 
    Next 
End If 

' Delete this when it's no longer needed 
MsgBox "Done" 

End Sub 
+0

代碼不工作的原因是我忘了,包括線路設置SSW變量SlideShowWindows(1)。 我現在不在工作,我會明天嘗試你的新密碼,並告訴你它是否有效。謝謝! – vkapadia

+0

現在效果更好,謝謝! – vkapadia