PDA

View Full Version : Identify and hide specific shapes on master slide



Operon
01-04-2011, 12:36 PM
I have a master slide (Slide2) with fifty shapes - Freeform1, Freeform2,.. etc. From subsequent slides I want to run a macro to hide a particular shape on the master slide and then return to the master slide. [Each slide from which the macro runs is arithmetically related to the shape I wish to hide.]

The code below is not doing it for me.

Sub Map()
Dim slide_no As Integer
Dim shape As shape
Dim shape_no As Long
Dim shapename As String

slide_no = ActiveWindow.View.Slide.SlideIndex
shape_no = slide_no + 1
With ActivePresentation.Slides(2)
shapename = "Freeform" & shape_no
For Each shape In ActivePresentation.Slides(2).Shapes
If shape.Name = shapename Then
ActivePresentation.Slides(2).Shapes("shapename").Visible = False
End If
Next
End With
On Error Resume Next
SlideShowWindows(1).View.GotoSlide 2
If Error <> 0 Then
ActivePresentation.SlideShowSettings.Run
SlideShowWindows(1).View.GotoSlide 2
End If

End Sub
Many thanks for any and all helpful suggestions.

Cheers,

John

John Wilson
01-04-2011, 11:02 PM
Try this:
Sub Map()
Dim slide_no As Integer
Dim shape As shape
Dim shape_no As Long
Dim shapename As String
'use SlideShowWindows(1) NOT Active Window
slide_no = SlideShowWindows(1).View.Slide.SlideIndex
'Is this relationship correct??
shape_no = slide_no + 1
'No need to loop
With ActivePresentation.Slides(2)
shapename = "Freeform " & CStr(shape_no)
On Error Resume Next
' NO "" around shapename
ActivePresentation.Slides(2).Shapes(shapename).Visible = False
End With
SlideShowWindows(1).View.GotoSlide 2
End Sub

Some versions have a bug where the screen doesn't update in show mode.

Operon
01-05-2011, 04:01 PM
John,

Many thanks. Works perfectly.

Cheers,

John