1
votes

I have a macro that is supposed to make every shape on a page visible (I have other macros that make them invisible). Here is the code:

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

This macro takes forever to run. I suspect this is because it is redrawing the screen every time a shape is made visible.

This is not necessary, in fact the slide isn't even shown on the screen when this macro is run (it runs on Slide 1 but makes the shapes on Slide 2 visible). Is there any way to make this run faster? Disable the screen refresh or something?

I tried Shyam's solution from http://www.vbaexpress.com/forum/showthread.php?33671-Solved-PP2010-ScreenUpdating-False but it doesn't work. His only goes up to 2010 and I'm using 2013.

1

1 Answers

1
votes

Your code doesn't work as shown. I changed it to this, which works pretty much instantly on a slide with 175 shapes:

' 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