Editing embedded PowerPoint from Excel VBA

I have a built-in PowerPoint presentation in an Excel workbook. How to change this (open, copy slides, add data to slides, close) using VBA?

+4
source share
1 answer

1. Add a link to the PowerPoint object model to your VBA application

In the VBA window, select Tools | References
Find the Microsoft Powerpoint 12.0 Object Library and check it

2. Select and activate a 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 upper left corner to see what it really called), and that it is on the active sheet.

3. Get a link to the view object

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

4. Manipulate them

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

 p.Slides.Add 1, ppLayoutBlank 

5. Deselect

The easiest way is to simply select a cell.

 [a1].Select 

Hope this helps!

+7
source

Source: https://habr.com/ru/post/1277098/


All Articles