首页 > 解决方案 > Powerpoint 自动更新图表链接宏

问题描述

我正在努力寻找有关如何制作宏以更新指向在 Powerpoint 演示文稿中链接的 Excel 图表的链接的信息。演示文稿设置在循环上,Excel 电子表格始终在后台打开。到目前为止,我有这个,但它似乎不起作用

Private Sub WebBrowser1_BeforeNavigate2(ByVal pDisp As Object, URL As Variant, Flags As Variant, TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean)
ActivePresentation.UpdateLinks
End Sub

我还在另一个威胁上找到了这段代码,但我不清楚,如何循环这个 VBA 让我们说在计时器基础上,或者在下一个幻灯片事件上。

Sub update2()

Dim myPresentation As PowerPoint.Presentation
Dim sld As PowerPoint.Slide
Dim shp As PowerPoint.Shape
Dim myChart As PowerPoint.Chart
Dim Wb As Object
Dim App As Object

Set myPresentation = ActivePresentation

For Each sld In myPresentation.Slides
    For Each shp In sld.Shapes
        If shp.HasChart Then
            Set myChart = shp.Chart
            myChart.ChartData.Activate
            myChart.Refresh
            Set Wb = myChart.ChartData.Workbook
            Set App = Wb.Application
            Wb.Close (0)
        End If
    Next
Next
App.Quit
End Sub

正如我所提到的,我的演示文稿正在循环播放,其中包含来自同一个电子表格的多个图表。

谢谢

标签: excelvbapowerpoint

解决方案


推荐阅读