PowerPoint Chart Copy Closing Mid-Format Procedure

WendyLou315

New Member
Joined
Nov 19, 2014
Messages
13
Programing a procedure which opens a .ppt template and copies in charts and tables from Excel for multiple generation of presentations (a Do Loop) for a new .ppt per record on a specific worksheet. What appears to be an every-other-time/record event, the pasting of an Excel chart is interrupted mid-process by closing PowerPoint after entering a WITH statement to place and size the chart on the first one of the WITH statement which is selecting the shape number of the chart just added (therefore before the procedure performs the PPT.Quit). Naturally the program cannot find the presentation to format the shape on the slide and all other work conducted in the PowerPoint presentation has been lost.

Here is a condensed version of the procedure but I CAN provide the whole thing. There are two tables copied to the PowerPoint which seem to have no issues with being added. To be clear: it works for the first record of the Excel worksheet, but the second ALWAYS fails and closes the .ppt before it can format the chart just copied to the slide.

Code:
'Slide 8 = Contour Overlay Chart
    Sheets("Contour Plot").Select
    'Copy Chart into PowerPoint
    ActiveSheet.ChartObjects("ContourPlot").Activate
    ActiveSheet.ChartObjects("ContourPlot").Activate
    ActiveSheet.ChartObjects("ContourPlot").Chart.CopyPicture _
        appearance:=xlScreen, Size:=xlScreen, Format:=xlPicture

PPT.ActivePresentation.Slides(8).Shapes.PasteSpecial Link:=0
NumShape = PPT.ActivePresentation.Slides(8).Shapes.Count
With PPT.ActivePresentation.Slides(8).Shapes(NumShape) 'Here is where it closes .ppt every OTHER instance from a loop before it gets to the next line
    .Height = 390
    .Left = 160
    .Top = 110
End With

Application.CutCopyMode = False

'Save and Close the PowerPoint presentation
PPT.ActivePresentation.Save
PPT.ActivePresentation.Close
'Stop the PowerPoint connection
PPT.Quit

'Clear the memory
Set PPT = Nothing
 
Last edited:

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top