PowerPoint 2016 图表在 VBA 更新后丢失数据 sheet

PowerPoint 2016 chart loses data sheet after VBA update

使用 VBA 在 PowerpPoint 2016 中更新 Powerpoint(不是嵌入式 excel 图表)后,当我右键单击图表并 select 编辑数据。如果我 select 图表上部 rHS 上的过滤器符号,我会收到此错误。

The Linked File is not Available to edit the link. Click edit links to files below.

超级 link 在点击后没有任何反应。

这是用于更新图表的代码

For Each oSH In ActivePresentation.Slides(2).Shapes

                oSH.Chart.SeriesCollection(1).values = "Sheet1!$B:$B" & maxrow  ' change the series range before opening and closing the workbook object
                oSH.Chart.SeriesCollection(1).XValues = "Sheet1!$A:$A" & maxrow  'max number showing is 6 data points

                    With oSH.Chart.ChartData

                            'this updates the values in the datasheet
                            .Workbook.sheets(1).Range("A1:B" & lrow - 2).Value = xlWorkBook.sheets(2).Range("A3:B" & lrow).Value

                    End With

经过几天的搜索和试验,我找到了解决问题的办法。我没有创建幻灯片或图表,但发现数据位于数据 sheet 上的 table 中。我编辑了 Excel sheet 中的数据并将 table 转换为一个范围。

奇怪的是,这解决了我的问题。