Hi all. I'm trying to edit the data of a chart in a PowerPoint presentation that is linked to Excel. Here is a code I found that looks similar to what I want to do

Sub test ()

Dim myChart As Chart
Dim myChartData As ChartData
Dim gWorkBook As Excel.Workbook
Dim gWorkSheet As Excel.Worksheet

Set myChart = ActivePresentation.Slides(2).Shapes("Chart7").Chart
Set myChartData = myChart.ChartData
myChartData.Activate

Set gWorkBook = myChart.ChartData.Workbook
Set gWorkSheet = gWorkBook.Worksheets(1)
gWorkSheet.Range("B2").Value = 1

gWorkBook.Close
Set gWorkSheet = Nothing
Set gWorkBook = Nothing
Set gChartData = Nothing
Set myChart = Nothing
End Sub
When I run it, it says "User-defined type not defined" though. Here's what I have:

This macro is in PowerPoint, not Excel.
The chart is on slide 2 of the PowerPoint presentation and is named "Chart7".
The Excel workbook is named Workbook1 and the first sheet on it that has the chart data is called Sheet1. It will already be open at the time that the macro is run.
The macro is designed to be run by clicking a button while the PowerPoint presentation is running.

What I ideally want to do is be able to edit the excel sheet in any way I want (setting B2 to 1 is just an example). If there's any way I can be more specific, please let me know. Any help would be greatly appreciated.