Hello forum,
I have charts in powerpoint which are linked to an excel workbook.
When trying to change the source data using .SetSourceData, nothing happens. It works if I manually change the data range first, and then re run the code, but I may aswell set the source data manually each time.
My code is written in excel vba 2010 & i'm using windows 7
The correct string is of the range is created, but the charts data source is not changed.
Any help on this would be great.
Thanks,
Ram
I have charts in powerpoint which are linked to an excel workbook.
When trying to change the source data using .SetSourceData, nothing happens. It works if I manually change the data range first, and then re run the code, but I may aswell set the source data manually each time.
My code is written in excel vba 2010 & i'm using windows 7
Code:
Sub firstbr()
'Requires a reference to the Microsoft PowerPoint Library via the Tools - Reference menu in the VBE
Dim ppApp As PowerPoint.Application
Dim ppSlide As PowerPoint.Slide
Dim SlideNumber As PowerPoint.SlideRange
'----------------------Slide 4--------------------------
On Error GoTo 0
Sheets("BR Exec Summary").Select
'Look for existing instance
On Error Resume Next
Set ppApp = GetObject(, "PowerPoint.Application")
On Error GoTo 0
'Make the instance visible
ppApp.Visible = True
'Copy & Paste into correct place
ppApp.ActiveWindow.View.GotoSlide (4)
Set ppSlide = ppApp.ActiveWindow.View.Slide
'top chart
col = Range("A2").End(xlToRight).Column
rw = Cells(2, col + 3).End(xlDown).Row
colst = Split(Cells(1, col + 2).Address(True, False), "$")
colend = Split(Cells(1, col + 3).Address(True, False), "$")
ppSlide.Shapes("Chart 10").Chart.SetSourceData Source:="='BR Exec Summary'!$" & colst(0) & "$2:$" & colend(0) & "$" & rw
The correct string is of the range is created, but the charts data source is not changed.
Any help on this would be great.
Thanks,
Ram