我正在运行(从PowerPoint)的代码:
我注意到,在整个PPT级别[via Info
]上都不存在到excel的链接,它们是故意链接到每个图表的,因此可以在不访问源excel文件的情况下编辑演示文稿。
该代码可以正常工作。
我认为存在一个持续存在的错误(代码现在可以正常运行),它关系到网络和内存稳定性(大约15张图表后失败),我希望按照为Powerpoint关闭屏幕更新来关闭屏幕更新。
我访问的所有图表都链接到其他工作簿。但是,当Excel工作簿暴露于PowerPoint时,即使代码处理了每个链接,链接源也不会显示在Locals
窗口中(下图显示该链接存在)
我翻转了自动化功能,从Excel访问PowerPoint包,结果相同。没有链接源。
使用Excel自动执行PowerPoint时,为什么在“本地”窗口中也无法使用完整的对象模型?
这是我偶然发现的局部故障,还是更广泛的问题?
下图显示了链接上的代码(ppl
变量,但是xlWB
变量没有Linksources)。
代码
Sub FastUpdate()
Dim sld As Slide
Dim shp As Shape
Dim pptchrt As Chart
Dim pptChrtData As ChartData
Dim xlWB As Excel.Workbook
Dim lngStart As Long
Dim strNew As String
Dim strMsg As String
Dim ppl As Variant
On Error GoTo cleanup
'set start position manually
'lngStart = 34
If lngStart = 0 Then lngStart = 1
'call custom function for user to pick file
'strNew = Getfile
strNew = "S:\Corporate Model\05 RSM submissions\05 May 2016\02 Checked RSMs\VFAT\Australia\Australia - Valuation and Financial Analysis template.xlsx"
For Each sld In ActivePresentation.Slides
If sld.SlideIndex >= lngStart Then
For Each shp In sld.Shapes
If shp.HasChart Then
Set pptchart = shp.Chart
Set pptChrtData = pptchart.ChartData
'open underlying excel file - doesn't just activate chart
pptChrtData.Activate
'
Set xlWB = pptChrtData.Workbook
'loop through all links
For Each ppl In xlWB.LinkSources
strMsg = strMsg & SlideNumber & " " & pptchart.Name & vbNewLine
xlWB.ChangeLink ppl, strNew
Next
xlWB.Close True
Set xlWB = Nothing
End If
Next shp
End If
Next sld
cleanup:
Set xlWB = Nothing
If Err.Number <> 0 Then MsgBox Err.Description, vbCritical
If Len(strMsg) > 0 Then MsgBox strMsg, vbOKOnly, "Completed"
End Sub
Locals和Watch窗口显示对象的属性。可以在此处找到Workbook对象的属性列表。
LinkSources是带有可选Type
参数的方法。
如果要调试LinkSources
,可以将其添加到“监视”窗口中:
或将返回值保存到本地变量中以在“本地”窗口中查看它。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句