【发布时间】:2013-02-03 18:34:52
【问题描述】:
我的问题是我已将图表粘贴到 powerpoint 中,并且我正在尝试通过 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