将 OLEObject 从 Excel 复制到新创建的 Powerpoint

发布于 2024-09-25 20:27:45 字数 469 浏览 3 评论 0原文

即使经过数小时的搜索,我仍很难正确使用 API。

基本上,我想从 Excel 文件执行以下操作。

1) 创建一个新的 Powerpoint 演示文稿和幻灯片。 [完成]

2) 将 OLEObject 从 Excel 文件复制到 Powerpoint 幻灯片中。

到目前为止我为没有做过什么。 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

请帮助我了解如何将 OLEObjects 从 Excel 文件复制到 Powerpoint 幻灯片中。

谢谢 。

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 .

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦情居士 2024-10-02 20:27:45

为什么不简单地复制并粘贴 OBJObjects?

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

编辑评论

粘贴方法应该返回一个 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

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文