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

如何使用vba更新powerpoint 2010中嵌入的excel链接,powerpoint,excel,hyperlink,vba,Powerpoint,Excel,Hyperlink,Vba,我的问题是,我已将图表粘贴到中,并试图通过Excel VBA更新嵌入的链接 我尝试了以下代码,但失败了: 代码1 AppPPT.Presentations.Open "D:\Demo.pptx", Untitled:=msoTrue AppPPT.ActivePresentation.UpdateLinks AppPPT.ActivePresentation.SaveAs "D:\Demo.pptx" 代码2 For i = 1 To AppPPT.Active

我的问题是,我已将图表粘贴到中,并试图通过Excel VBA更新嵌入的链接

我尝试了以下代码,但失败了:

代码1

    AppPPT.Presentations.Open "D:\Demo.pptx", Untitled:=msoTrue
    AppPPT.ActivePresentation.UpdateLinks
    AppPPT.ActivePresentation.SaveAs "D:\Demo.pptx"
代码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
代码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

我花了几天的时间来尝试,终于达到了目的

AppPPT.ActivePresentation.Slides(1).Shapes("Chart 75").LinkFormat.Update
和特征线代码

AppPPT.ActivePresentation.Slides(1).Shapes("Chart 75").LinkFormat.BreakLink

谢谢大家!!一旦我能够识别对象/图表,它就起作用了。(单击“绘图工具”、“排列”、“选择窗格”下的对象。)这是我的代码。现在我可以运行它,它会立即更新我的所有链接。我不想将它设置为自动更新,因为当我发送它时,收件人会收到一条关于链接的警告消息,这让人困惑。再次感谢

Sub update()

ActivePresentation.Slides(1).Shapes("Object 1").LinkFormat.update
ActivePresentation.Slides(1).Shapes("Object 2").LinkFormat.update

ActivePresentation.Slides(4).Shapes("Chart 5").LinkFormat.update

ActivePresentation.Slides(5).Shapes("Object 2").LinkFormat.update
ActivePresentation.Slides(5).Shapes("Chart 5").LinkFormat.update

ActivePresentation.Slides(6).Shapes("Object 1").LinkFormat.update
ActivePresentation.Slides(6).Shapes("Chart 4").LinkFormat.update
ActivePresentation.Slides(6).Shapes("Chart 6").LinkFormat.update

ActivePresentation.Slides(7).Shapes("Object 1").LinkFormat.update
ActivePresentation.Slides(7).Shapes("Chart 4").LinkFormat.update
ActivePresentation.Slides(7).Shapes("Chart 5").LinkFormat.update

ActivePresentation.Slides(8).Shapes("Object 3").LinkFormat.update

ActivePresentation.Slides(9).Shapes("Chart 4").LinkFormat.update

ActivePresentation.Slides(10).Shapes("Object 1").LinkFormat.update

ActivePresentation.Slides(11).Shapes("Object 6").LinkFormat.update
ActivePresentation.Slides(11).Shapes("Object 7").LinkFormat.update
ActivePresentation.Slides(11).Shapes("Object 8").LinkFormat.update

End Sub

这将是很好的看到一个示例PPT文件,链接可以直接在图表中,或通过图表下面的Excel。+1显示你尝试了什么:)你看到了@brettdj的这篇文章吗谢谢你的回复,我遇到了另一个问题,我正在尝试将原始ppt复制到另一个ppt,我需要删除复制ppt中的所有更新链接。这可能吗?如果可能,请提供任何示例代码。顺便说一句,这是PowerPoint中的VBA,而不是Excel中的。我实际上保存了一个ppt,用于存放我的宏,因此,我发送的ppt不必是宏友好格式。如果有人知道更简单的方法,请告诉我。在过去的几个月里,我一直在寻找解决方案。