从Excel VBA中编辑嵌入式PowerPoint

时间:2021-04-28 13:05:52

I have an embedded PowerPoint presentation in an Excel workbook. How can I edit this (open, copy slides, add data to slides, close) using VBA?

我在Excel工作簿中有一个嵌入式PowerPoint演示文稿。如何使用VBA编辑(打开、复制幻灯片、向幻灯片添加数据、关闭)?

1 个解决方案

#1


7  

1. Add a reference to the PowerPoint Object Model to your VBA application

1。向VBA应用程序添加对PowerPoint对象模型的引用

From the VBA window, choose Tools | References
Look for Microsoft Powerpoint 12.0 Object Library and check it

从VBA窗口中,选择工具|参考,查找Microsoft Powerpoint 12.0对象库并进行检查。

2. Select and activate the PowerPoint presentation object

2。选择并激活PowerPoint演示对象。

ActiveSheet.Shapes("Object 1").Select
Selection.Verb Verb:=xlOpen

Note: this code assumes that the PowerPoint object is named Object 1 (look in the top left corner to see what it's really named) and that it is on the active sheet.

注意:这段代码假设PowerPoint对象名为object 1(请在左上角查看它的真正名称),并且它在活动表单上。

3. Get a reference to the Presentation object

3所示。获取对表示对象的引用

Dim p As PowerPoint.Presentation
Set p = Selection.Object

4. Manipulate it

4所示。操纵它

All the methods and properties of a presentation object are available to you. Here's an example of adding a slide:

表示对象的所有方法和属性都是可用的。这里有一个添加幻灯片的例子:

p.Slides.Add 1, ppLayoutBlank

5. Deselect it

5。取消选择它

The easiest way is just to select a cell.

最简单的方法就是选择一个单元格。

[a1].Select

Hope that helps!

希望会有帮助!

#1


7  

1. Add a reference to the PowerPoint Object Model to your VBA application

1。向VBA应用程序添加对PowerPoint对象模型的引用

From the VBA window, choose Tools | References
Look for Microsoft Powerpoint 12.0 Object Library and check it

从VBA窗口中,选择工具|参考,查找Microsoft Powerpoint 12.0对象库并进行检查。

2. Select and activate the PowerPoint presentation object

2。选择并激活PowerPoint演示对象。

ActiveSheet.Shapes("Object 1").Select
Selection.Verb Verb:=xlOpen

Note: this code assumes that the PowerPoint object is named Object 1 (look in the top left corner to see what it's really named) and that it is on the active sheet.

注意:这段代码假设PowerPoint对象名为object 1(请在左上角查看它的真正名称),并且它在活动表单上。

3. Get a reference to the Presentation object

3所示。获取对表示对象的引用

Dim p As PowerPoint.Presentation
Set p = Selection.Object

4. Manipulate it

4所示。操纵它

All the methods and properties of a presentation object are available to you. Here's an example of adding a slide:

表示对象的所有方法和属性都是可用的。这里有一个添加幻灯片的例子:

p.Slides.Add 1, ppLayoutBlank

5. Deselect it

5。取消选择它

The easiest way is just to select a cell.

最简单的方法就是选择一个单元格。

[a1].Select

Hope that helps!

希望会有帮助!