VBA with standard PPT objects

  • Thread starter Thread starter Stugrad98
  • Start date Start date
S

Stugrad98

Hi,

I know how to manipulate VBA controls and properties-- for instance, how to
make a picture box lose visibility. But I am curious how I go about
manipulating standard PPT objects, like PPT shapes, placeholders, etc. For
instance, if I drew a regular shape, how can I make that shape lose
visibility.

Thanks,
Stu
 
Other than the obvious (Custom animations using Triggers), you can assign a
name to that object using VBA and set it's visible property to False, just
like any object on a slide (except built-in placeholders). The trick is
knowing the name that PowerPoint assigned to that object (not always easy to
determine). The following code when run will bring up a dialog box showing
the name of that object (like Autoshape124). You merely type a new name
using proper syntax (like MyShape) and press ENTER to accept that name.
Here is that part of code:

=========Code starts here========

Sub NameShape()
Dim Name$
On Error GoTo AbortNameShape

If ActiveWindow.Selection.ShapeRange.Count = 0 Then
MsgBox "No Shapes Selected"
Exit Sub
End If
Name$ = ActiveWindow.Selection.ShapeRange(1).Name

Name$ = InputBox$("Give this shape a name", "Shape Name", Name$)

If Name$ <> "" Then
ActiveWindow.Selection.ShapeRange(1).Name = Name$
End If
Exit Sub

AbortNameShape:
MsgBox Err.Description

End Sub

=========Code Stops here=========

The next thing is to know the syntax for the line of code for the object on
a given slide. For example, using the object named "MyShape" on slide 10 of
my presentation, the line of code to hide it would be:

ActivePresentation.Slides(10).Shapes("MyShape").Visible = False

Hope this helps!
 
Back
Top