[英]Editing Embedded PowerPoint from Excel VBA
I have an embedded PowerPoint presentation in an Excel workbook. 我在Excel工作簿中有一个嵌入式PowerPoint演示文稿。 How can I edit this (open, copy slides, add data to slides, close) using VBA?
如何使用VBA编辑(打开,复制幻灯片,向幻灯片添加数据,关闭)?
1. Add a reference to the PowerPoint Object Model to your VBA application 1.将PowerPoint对象模型的引用添加到VBA应用程序
From the VBA window, choose Tools | 在VBA窗口中,选择“ 工具”| References
参考
Look for Microsoft Powerpoint 12.0 Object Library and check it 查找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.获取Presentation对象的引用
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! 希望有所帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.