Pasting linked range or chart from Excel to PowerPoint

Dr. Demento

Well-known Member
Joined
Nov 2, 2010
Messages
551
I'm having trouble finding an example of the method of pasting a range or chart from Excel into PowerPoint as a linked object. A link would be great.

Thanks y'all.
 

Some videos you may like

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
5,634
Office Version
365
Platform
Windows
The code below (found in the link) worked first time for me
https://www.thesmallman.com/blog/2016/9/16/copy-and-paste-an-excel-chart-into-powerpoint-with-vba

Test (unmodified) like this
- add a chart to the FIRST sheet in your workbook
- place the code below in a module
- In VBA add reference to Microsoft PowerPoint object library (see link for instructions)
- run the code

A new presentation is created with a linked chart in the first slide
After testing it unmodified, then modify code to suit your needs

Code:
Option Explicit
Sub CopyChartPP()
   Dim oPPT As Object
   Dim oPres As Object
   Dim oSld As Object
   Dim oWS As Worksheet
   Dim oCHT As ChartObject

   Set oPPT = CreateObject("PowerPoint.Application")
   Set oPres = oPPT.Presentations.Add(msoTrue)
   Set oSld = oPres.Slides.Add(1, ppLayoutTitleOnly)
   Set oWS = ActiveWorkbook.Worksheets(1)
   Set oCHT = oWS.ChartObjects(1)
   oCHT.Select

   ActiveChart.ChartArea.Copy
   oSld.Shapes.PasteSpecial link:=msoTrue
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,095,350
Messages
5,443,953
Members
405,258
Latest member
daveyf

This Week's Hot Topics

Top