从Excel VBA编辑嵌入式PowerPoint [英] Editing Embedded PowerPoint from Excel VBA
问题描述
我在Excel工作簿中有一个嵌入式PowerPoint演示文稿.如何使用VBA编辑(打开,复制幻灯片,向幻灯片添加数据,关闭)?
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?
推荐答案
1.将对PowerPoint对象模型的引用添加到您的VBA应用程序中
在VBA窗口中,选择工具|参考
查找 Microsoft Powerpoint 12.0对象库并进行检查
From the VBA window, choose Tools | References
Look for Microsoft Powerpoint 12.0 Object Library and check it
2.选择并激活PowerPoint演示文稿对象
ActiveSheet.Shapes("Object 1").Select
Selection.Verb Verb:=xlOpen
注意:此代码假定PowerPoint对象被命名为对象1 (查看左上角以查看其实际名称),并且该对象位于活动工作表上.
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.
3.获取对Presentation对象的引用
Dim p As PowerPoint.Presentation
Set p = Selection.Object
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.取消选择
最简单的方法就是选择一个单元格.
The easiest way is just to select a cell.
[a1].Select
希望有帮助!
这篇关于从Excel VBA编辑嵌入式PowerPoint的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!