Powerpoint Alchemy Amazing techniques and tips
Amazing techniques which will transform your use of PowerPoint presentations. Make your presentation stand out from the crowd!

About

Modifying Shapes with vba

You can modify shapes in several ways using vba. Examples include changing size, position, visibility and fill. First though you need to reference the shape you need to work with.

Often you will see code like this:

ActivePresentation.Slides(2).Shapes(3).Visible = False

This code will work well.... until you add slides or change the order of shapes on a slide. Once this happens the code will fail or do unexpected things as the slide and shape numbers will have changed.

Using Names

One answer is to use slide names and shape names which are not easily changed. All slides and shapes have default names which can be read with this vba.

Sub identifyme()
On Error GoTo errhandler
MsgBox "The shape is named " & ActiveWindow.Selection.ShapeRange.Name _
& Chr$(13) & "The slide is named " & ActiveWindow.Selection.SlideRange.Name
Exit Sub
errhandler:
MsgBox "There's an error, maybe you've selected more that one shape?"
End Sub

Once you have the names you can use:

ActivePresentation.Slides("slidename").Shapes("shapename").Visible = False

You can also use vba to rename a shape or slide:

Sub nameshape()
On Error GoTo errhandler
ActiveWindow.Selection.ShapeRange.Name = InputBox("Name me")
Exit Sub
errhandler:
MsgBox "There's an error, maybe you've selected more that one shape?"
End Sub

Sub nameslide()
On Error GoTo errhandler
ActiveWindow.Selection.SlideRange.Name = InputBox("Name me")
Exit Sub
errhandler:
MsgBox "There's an error, maybe you've selected more that one shape?"
End Sub

Other Answers

To change a shape on the CURRENT slide in slide show view:

ActivePresentation.SlideShowWindow.View.Slide.Shapes("shapename").Visible = False

To get a reference to the current slide:

Dim i As Integer
i = ActivePresentation.SlideShowWindow.View.CurrentShowPosition

You can then use "i" to change shapes on eg the NEXT slide

ActivePresentation.Slides(i+1).Shapes("shapename").Visible = False

Don't know how to use vba? See here

With an online education, you can take powerpoint lessons and learn english. With online college courses, you can complete a degree program in no time.



 


This website is sponsored by Technology Trish Ltd
© Technology Trish 2007
Registered in England and Wales No.5780175