Dim oshp As Shape, oXL As Object
Set oshp = ActivePresentation.Slides(1).Shapes(1)
Set oXL = oshp.OLEFormat.Object
Dim chrt As Chart
Set chrt = ActivePresentation.Slides(2).Shapes(3).Chart
chrt.SetSourceData oXL.Sheets("013").Range("A1:D12")
Dim oshp As Shape, oXL As Object
Set oshp = ActivePresentation.Slides(1).Shapes(1)
Set oXL = oshp.OLEFormat.Object
oXL.Sheets("013").Range("A15") = "hello Excel"
Dim rng As Range
Set rng = oXL.Sheets("013").Range("A1:D12")
chrt.SetSourceData Source:=rng
with a reference to excel but it barfs with exactly the same problem. I just don't know how I could convert the range into a string.' Create a chart on a PowerPoint slide from the PowerPoint VBE
' Requires a reference to the Excel library in it's current form but could be modified for late binding
Sub CreateChartFromEmbeddedWorkbook()
Dim oSrcDataShp As Shape, oWB1 As Object
Set oSrcDataShp = ActivePresentation.Slides(1).Shapes(1)
Set oWB1 = oSrcDataShp.OLEFormat.Object
Dim oTgtChrtShp As Shape
Set oTgtChrtShp = ActivePresentation.Slides(3).Shapes.AddChart(xl3DColumn)
Dim oTgtChrt As Chart
Set oTgtChrt = oTgtChrtShp.Chart
Dim oWB2 As Excel.Workbook
Dim oWS2 As Excel.Worksheet
Set oWB2 = oTgtChrt.ChartData.Workbook
Set oWS2 = oWB2.Worksheets(1)
' Resize the data table to match the source data
oWS2.ListObjects("Table1").Resize oWS2.Range("A1:D13")
Dim iRow As Integer, iCol As Integer
For iRow = 1 To 13
For iCol = 1 To 4
' Setting the whole range doesn't appear to work so do it cell by cell
oWS2.Cells(iRow, iCol) = oWB1.Sheets("013").Cells(iRow, iCol)
Next
Next
Set oSrcDataShp = Nothing: Set oTgtChrtShp = Nothing
Set oWB1 = Nothing: Set oWB2 = Nothing: Set oWS2 = Nothing
Set oTgtChrt = Nothing
End Sub
How do you want to determine the range?
pls try
Open in new window
Regards