I'm struggling to get the API usage correct, even after hours of searching.
即使经过数小时的搜索,我仍在努力使API使用正确。
Basically, I want to do the following from my Excel file.
基本上,我想从我的Excel文件中执行以下操作。
1) Create a new Powerpoint presentation and slide. [DONE]
1)创建一个新的Powerpoint演示文稿和幻灯片。 [DONE]
2) Copy OLEObject from the Excel file into the Powerpoint slide.
2)将OLEObject从Excel文件复制到Powerpoint幻灯片中。
What I have done so far for the no. 2 is
到目前为止,我做了什么。 2是
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.
请帮我看看如何将OLE文件从Excel文件复制到Powerpoint幻灯片。
Thanks .
谢谢 。
1 个解决方案
#1
2
Why not simply copy and paste the OBJObjects?
为什么不简单地复制和粘贴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:
paste方法应该返回一个ShapeRange对象。您可以在返回的ShapeRange中设置第一个形状的顶部和左侧属性。我没有测试这个(我不使用VB.NET)但它应该是这样的:
Dim sr as ShapeRange
Dim sh as Shape
Set sr = pptSlide.Shapes.Paste()
Set sh = sr.Item(1)
sh.Left = 10
sh.Top = 10
#1
2
Why not simply copy and paste the OBJObjects?
为什么不简单地复制和粘贴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:
paste方法应该返回一个ShapeRange对象。您可以在返回的ShapeRange中设置第一个形状的顶部和左侧属性。我没有测试这个(我不使用VB.NET)但它应该是这样的:
Dim sr as ShapeRange
Dim sh as Shape
Set sr = pptSlide.Shapes.Paste()
Set sh = sr.Item(1)
sh.Left = 10
sh.Top = 10