views:

35

answers:

1

Hi,

I'm struggling to get the API usage correct, even after hours of searching.

Basically, I want to do the following from my Excel file.

1) Create a new Powerpoint presentation and slide. [DONE]

2) Copy OLEObject from the Excel file into the Powerpoint slide.

What I have done so far for the no. 2 is

Dim s As Shapes
For Each Obj in Worksheets("TEMPLATE").OLEObjects
  'Copy OLEObjects from Excel to Powerpoint slide
  Set s = pptSlide.Shapes.AddOLEObject '( ... ?? ... )
Next Obj

Please help me on how to copy the OLEObjects from the Excel file into the Powerpoint slide.

Thanks .

+1  A: 

Why not simply copy and paste the OBJObjects?

For Each Obj in Worksheets("TEMPLATE").OLEObjects
  'Copy OLEObjects from Excel to Powerpoint slide
  Obj.Copy()
  pptSlide.Shapes.Paste()
Next Obj

EDIT FOR COMMENT

The paste method should return a ShapeRange object. You can set the top and left properties of the first shape in your returned ShapeRange. I didn't test this (and I don't use VB.NET) but it should be something like this:

Dim sr as ShapeRange
Dim sh as Shape

Set sr = pptSlide.Shapes.Paste()
Set sh = sr.Item(1)
sh.Left = 10
sh.Top = 10
Mark
Sounds like a good suggestion. Any idea how to position it at certain x,y ?
zaidwaqi
@zaidwaqi, see edits above.
Mark