如何使用vba更新powerpoint 2010中的嵌入式Excel链接

Din*_*eer 4 excel powerpoint vba hyperlink excel-vba

我的问题是我已将我的图表粘贴到,我正在尝试通过Excel-VBA更新嵌入式链接.

我已经尝试过以下代码并且失败了:

代码1

    AppPPT.Presentations.Open "D:\Demo.pptx", Untitled:=msoTrue
    AppPPT.ActivePresentation.UpdateLinks
    AppPPT.ActivePresentation.SaveAs "D:\Demo.pptx"
Run Code Online (Sandbox Code Playgroud)

代码2

    For i = 1 To AppPPT.ActivePresentation.Slides.Count
    For s = 1 To AppPPT.ActivePresentation.Slides(i).Shapes.Count
        If AppPPT.ActivePresentation.Slides(i).Shapes(s).Type = msoLinkedOLEObject Then
            AppPPT.ActivePresentation.Slides(i).Shapes(s).LinkFormat.Update
        End If
    Next s
Next i
Run Code Online (Sandbox Code Playgroud)

代码3

    Set PPTTemplate = AppPPT.Presentations.Open("D:\Demo.pptx")

    ' update chart
    Dim osld As Slide
    Dim oshp As PowerPoint.Shape

    For Each osld In PPTTemplate.Slides
    For Each oshp In osld.Shapes
    With oshp
    If .HasChart Then
    .Chart.ChartData.Activate
    .Chart.ChartData.Workbook.Close
    .Chart.Refresh
    End If
    End With
    Next oshp
    Next osld

    AppPPT.Activate
Run Code Online (Sandbox Code Playgroud)

Din*_*eer 5

我花了几天时间尝试它,实现了它

AppPPT.ActivePresentation.Slides(1).Shapes("Chart 75").LinkFormat.Update
Run Code Online (Sandbox Code Playgroud)

和BreakLines代码

AppPPT.ActivePresentation.Slides(1).Shapes("Chart 75").LinkFormat.BreakLink
Run Code Online (Sandbox Code Playgroud)