我有一个每周生成的ppt。我已经创建了一个用于更新链接图表的vbscript ..但是我找不到如何识别我用于在ppt中创建表格的Excel工作表...
Dim pptChart
Dim pptChartData
Dim xlWorkbook
Dim sld
Dim shp
'opent the ppt
strPresPath = "C:\oldpptlocation.pptx"
Set oPPTApp = CreateObject("PowerPoint.Application")
oPPTApp.Visible = True
Set oPPTFile = oPPTApp.Presentations.Open(strPresPath)
For Each sld In oPPTFile.Slides 'ActivePresentation.Slides
For Each shp In sld.Shapes
If shp.HasChart Then
Set pptChart = shp.Chart
Set pptChartData = pptChart.ChartData
pptChartData.Activate
Set pptWorkbook = pptChartData.Workbook
On Error Resume Next
'update first link
pptWorkbook.UpdateLink pptWorkbook.LinkSources(1)
'On Error GoTo 0
pptChart.Refresh
pptWorkbook.Close True
End If
Next
Next
oPPTFile.SaveAs ("C:\updated_ppt.pptx")
oPPTFile.Close
oPPTApp.Quit
Set pptWorkbook = Nothing
Set pptChartData = Nothing
Set pptChart = Nothing
答案 0 :(得分:0)
您目前正在检查图表的每个形状,您需要添加ElseIf
来测试形状.HasTable
。
If shp.HasChart Then
'your code to update chart
ElseIf shp.HasTable Then
'your code to update table
End If