0
votes

I´m trying to modify ChartData (values) in Powerpoint by using Excel-VBA. The ChartData is not linked to the other Excel Workbook.

Checks: - PowerPoint is open - required Presentation is open - The Chart is on Slide 4

Behavior: - Chart Title Changes - Workbook with ChartData opens - Runtime Error '424' : Objeckt Required - Debugging marks the following line:

Chart.ChartData.Workbook.Worksheets("Tabelle1").Range("B2:B5").Value = 50

Hope somebody can help me out... :-)

Sub ModifyChartData()

Dim pptApp As Object
Dim pptPres As Presentation

Set pptApp = GetObject(, "PowerPoint.Application")
Set pptPres = pptApp.ActivePresentation


pptPres.Slides(4).Shapes("Diagramm1").Chart.ChartTitle.Text = "Sales Overview"
pptPres.Slides(4).Shapes("Diagramm1").Chart.ChartData.Activate
Chart.ChartData.Workbook.Worksheets("Tabelle1").Range("B2:B5").Value = 50
Workbooks.Close

End Sub
1

1 Answers

1
votes

Example:

enter image description here

Code:

Set pptApp = GetObject(, "PowerPoint.Application")
Set pptPres = pptApp.ActivePresentation
pptPres.Slides(1).Shapes(1).Chart.ChartTitle.Text = "Sales Overview"
pptPres.Slides(1).Shapes(1).Chart.ChartData.Activate
pptPres.Slides(1).Shapes(1).Chart.ChartData.Workbook.Worksheets("Blad1").Range("B2:B5").Value = 50

Result:

enter image description here