VB PPT adding autoshapes

L

lance-news

Hello,

I am trying to create a macro to add autoshapes to a spreadsheet in
powerpoint. Can anyone spot the problem. Keeps bombing out on this line:
ShapeObject.Shapes.AddShape(9, 40.5, 16.5, 22.5, 20.25).Select


Sub test()

Dim SlideObject As Slide
Dim ShapeObject As Shape
For Each SlideObject In Application.ActivePresentation.Slides
' Inner loop goes through every shape in the presentation
For Each ShapeObject In SlideObject.Shapes
' Check if the shape is an OLE object
If ShapeObject.Type = 7 Then
ShapeObject.Shapes.AddShape(9, 40.5, 16.5, 22.5, 20.25).Select
End If
Next ShapeObject
Next SlideObject
End Sub
 
G

Guest

Lance,
If you wish to add a shape within an embedded worksheet, you need to activate the embedded object and then add the autoshape on it and then update the sheet in the Presentation.

Your syntax is incorrect. You cannot reference the excel sheet by the PowerPoint shape. You need to activate the object by getting a reference to the excel object - ShapeObject.OLEFormat.Object

Once you get the reference to the object, then you can proceed to try an add the autoshape within that object.

Regards
Shyam Pillai

http://www.mvps.org/skp




----- (e-mail address removed) wrote: -----

Hello,

I am trying to create a macro to add autoshapes to a spreadsheet in
powerpoint. Can anyone spot the problem. Keeps bombing out on this line:
ShapeObject.Shapes.AddShape(9, 40.5, 16.5, 22.5, 20.25).Select


Sub test()

Dim SlideObject As Slide
Dim ShapeObject As Shape
For Each SlideObject In Application.ActivePresentation.Slides
' Inner loop goes through every shape in the presentation
For Each ShapeObject In SlideObject.Shapes
' Check if the shape is an OLE object
If ShapeObject.Type = 7 Then
ShapeObject.Shapes.AddShape(9, 40.5, 16.5, 22.5, 20.25).Select
End If
Next ShapeObject
Next SlideObject
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top