Sub
PPT_ChangeChart()
With
ActivePresentation.Slides(1)
Dim
oChart
As
Chart
Dim
oChartData
As
ChartData
Dim
gWorkBook
As
Excel.Workbook
Dim
gWorkSheet
As
Excel.Worksheet
Set
oChart = ActivePresentation.Slides(1).Shapes(1).Chart
Set
oChartData = oChart.ChartData
oChartData.Activate
Set
gWorkBook = oChartData.Workbook
Set
gWorkSheet = gWorkBook.Worksheets(
"Sheet1"
)
gWorkSheet.Cells(2, 1).Value =
"Product A"
gWorkSheet.Cells(3, 1).Value =
"Product B"
gWorkSheet.Cells(4, 1).Value =
"Product C"
gWorkSheet.Cells(5, 1).Value =
"Product D"
gWorkSheet.Cells(6, 1).Value =
"Product E"
gWorkSheet.ListObjects(
"Table1"
).Resize gWorkSheet.Range(
"A1:D6"
)
gWorkBook.Application.Quit
oChart.Refresh
Set
gWorkSheet =
Nothing
Set
gWorkBook =
Nothing
Set
oChartData =
Nothing
Set
oChart =
Nothing
End
With
End
Sub