PPT
简洁、优雅、高效
通常我们需要把EXCEL中的图表在PPT中展示出来。如图:
羊羊羊心里一万头羊路过,难道又要重做一遍,
天空一片乌鸦飞过!点解咧?
羊羊羊历经千辛万苦,九九八十一难,终于找到办法。
让我们拭目以待。
代码如下:
Sub 更新链接()
Dim sld As Slide
Dim sh As Object
Dim a As String
Dim c As String
a = ActivePresentation.Path & '\'
For Each sld In ActivePresentation.Slides
For Each sh In sld.Shapes
If sh.Type = msoLinkedOLEObject Then
c = StrReverse(sh.LinkFormat.SourceFullName)
sh.LinkFormat.SourceFullName = a & StrReverse(Left(c, InStr(c, '\') - 1))
sh.LinkFormat.Update
End If
Next
Next
MsgBox '更新完毕'
End Sub
Sub 刷新数据()
Dim sld As Slide
Dim sh As Object
For Each sld In ActivePresentation.Slides
For Each sh In sld.Shapes
If sh.Type = msoLinkedOLEObject Then
sh.LinkFormat.Update
End If
Next
Next
MsgBox '数据更新完毕'
End Sub
PS:以上代码要求ppt跟excel数据源放在同一文件加下,否者会出错.
联系客服