在 PowerPoint 中使用 VBA 从图表点获取数据

Use VBA to get data from chart points in PowerPoint

我在 PowerPoint 中有一个气泡图,转到 "Edit Data" 不起作用(Excel 进程打开但电子表格没有--我试过 DLL 在 this link,但没有成功)。所以我只想用 VBA 遍历图表中的所有点并获取关联的数据(debug.print 很好)。这包括每个点的三个数据值:x、y 和大小。不幸的是,PowerPoint 似乎只是将其视为一系列数据——y 值。我设置cht等于图表对象,然后sercol = cht.SeriesCollection和sercol.Countreturns的值为1。如果我set ser = cht.SeriesCollection(1)vals = ser.Values,我可以循环通过所有并打印 y 坐标的值,但我不知道如何获得 x 坐标和大小(cht.SeriesCollection(2) 无效)。有没有办法获取与气泡图中的点关联的其他两个数据值?

If I set ser = cht.SeriesCollection(1) and vals = ser.Values, I can loop through all and print the value of the y coordinate, but I can't figure out how to get to the x coordinate

Dim xVals as Variant
xVals = ser.XValues
Debug.Print Join(xVals, ", ")

and size (cht.SeriesCollection(2) is not valid).

不确定为什么要尝试如果图表只有一个系列,这会引发错误(预期),下标超出范围。

对于气泡大小,该系列有一个 .BubbleSizes 属性,应该 return 一个字符串:

Dim bbls
bbls = ser.BubbleSizes
Debug.Print bbls

它可能 return 你的情况是一个数组,如果是这样,你只需要稍微调整一下。