【发布时间】:2018-06-07 11:23:29
【问题描述】:
我需要找到一种方法来将图表数据标签从 PowerPoint 图表提取到 Excel,因为给我的 PowerPoint 图表很多次都损坏了链接数据。
我写了下面的代码,但我不知道For Each datapoint In chtnow.SeriesCollection(1).Points...之后要做什么
Sub Extract_Datalabels()
'Goal: To extract datalabels of Chart's series collection and write to excel
Dim datapoint As Point
Dim sh As Shape
Dim sld As Slide
Dim chtnow As Chart
Dim label As DataLabel
Dim xlApp As New Excel.Application
Dim xlWorkbook As Excel.Workbook
Dim xlworksheet As Excel.Worksheet
Set xlWorkbook = xlApp.Workbooks.Add
Set xlworksheet = xlWorksheets.Add
xlApp.Visible = True
Set chtnow = ActiveWindow.Selection.ShapeRange(1).Chart
For Each datapoint In chtnow.SeriesCollection(1).Points
'Extract data labels
If datapoint.HasDataLabel Then
[No clue how to write to Excel]
End If
Next
End Sub
【问题讨论】:
-
这不是一个例子,但它已经有问题了。代码应该在发布之前进行测试。 (见minimal reproducible example)
-
另外,在 [每个] 模块的顶部 [总是] 使用
Option Explicit。
标签: excel vba charts label powerpoint