Updating Source Data in powerpoint charts

Ram_Patel

New Member
Joined
Nov 8, 2013
Messages
4
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

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
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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