【问题标题】:How to update embeded excel links in powerpoint 2010 using vba如何使用 vba 更新 powerpoint 2010 中的嵌入式 excel 链接
【发布时间】:2013-02-03 18:34:52
【问题描述】:

我的问题是我已将图表粘贴到 中,并且我正在尝试通过 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

【问题讨论】:

  • 最好能看到一个样例PPT文件,链接可以直接在图表中,也可以通过图表下方的Excel。
  • + 1 用于显示您尝试过的内容 :)
  • 你看到@brettdj stackoverflow.com/questions/9207267/…的这个帖子了吗
  • 感谢您的回复,我有另一个问题,我正在尝试将原始 ppt 复制到另一个 ppt,我需要删除重复 ppt 中的所有更新链接这可能吗?如果可以请给我任何示例代码。

标签: powerpoint excel hyperlink powerpoint vba


【解决方案1】:

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

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

和断线代码

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

【讨论】:

    【解决方案2】:

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

    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
    

    【讨论】:

    • 顺便说一句 - 这是 PowerPoint 中的 VBA - 不在 Excel 中。
    • 我实际上保存了一个 PPT 来存放我的宏,所以我发送的 ppt 不必是宏友好的格式。
    • 如果有人知道更简单的方法,请告诉我。过去几个月我一直在寻找解决方案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-23
    • 2013-08-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多