Editing Embedded PowerPoint from Excel VBA

最后都变了- 提交于 2019-12-10 17:25: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?


回答1:


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

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

2. Select and activate the PowerPoint presentation object

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.

3. Get a reference to the Presentation object

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

4. Manipulate it

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

The easiest way is just to select a cell.

[a1].Select

Hope that helps!



来源:https://stackoverflow.com/questions/124375/editing-embedded-powerpoint-from-excel-vba

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!