Pasting charts and tables into Power point

ulster0709

New Member
Joined
Aug 14, 2016
Messages
13
Hi Experts,


I have just learned <acronym title="visual basic for applications" style="border-width: 0px 0px 1px; border-bottom-style: dotted; border-bottom-color: rgb(0, 0, 0); cursor: help; color: rgb(51, 51, 51); background-color: rgb(250, 250, 250);">vba</acronym> few months ago and I got a problem that I havent been able to solve, could you help me or give me some advice please.

I have an excel vba code that works fine for
copying and pasting a chart from Excel into powerpoint, but it doesnt paste it into the placeholder, I am just wondering how should the code be amended in order to paste it into a placeholder, see the code below
Option Explicit

Sub Marcro3()
Dim PPT As Object
Set PPT = CreateObject("PowerPoint.Application")
PPT.Visible = True
PPT.Presentations.Open Filename:="path"
copy_chart "report", 3, "Chart 1" ' Name of the sheet to copy graph and slide number the graph is to be pasted in
'PPT.Save
'PPT.Close

End Sub

Public Function copy_chart(sheet, slide, name)


Dim PPApp As Object
Dim PPPres As Object
Dim PPSlide As Object
Dim nPlcHolder As Long

Set PPApp = CreateObject("Powerpoint.Application")
Set PPApp = GetObject(, "Powerpoint.Application")
Set PPPres = PPApp.ActivePresentation



PPApp.ActiveWindow.View.GotoSlide (slide)


Worksheets(sheet).Activate
ActiveSheet.ChartObjects(name).Chart.CopyPicture _
Appearance:=xlScreen, Size:=xlScreen, Format:=xlPicture



Set PPSlide = PPPres.slides(PPApp.ActiveWindow.Selection.SlideRange.SlideIndex)


With PPSlide
' paste and select the chart picture
.Shapes.Paste.Select

End With

' Clean up
Set PPSlide = Nothing
Set PPPres = Nothing
Set PPApp = Nothing
End Function


Below is more information about the problem

Excel
Spreadsheet name: Report generator
Spreadsheet location: (Already activate)
Worksheet: Summary
Chart name: Chart 1

Powerpoint
Powerpoint name: report
powerpoint location: (already activate)
Slide: P.3
Placeholder position: the one of the left, I am not sure whether there is a name for the placeholders on powerpoint (there are two placeholders on P.3, one on the right, the other one on the left)


Thank you!

 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

Forum statistics

Threads
1,214,907
Messages
6,122,183
Members
449,071
Latest member
cdnMech

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