通过PowerPoint自动化Excel – 本地窗口不暴露全部对象模型(即Linksources)

背景

我正在运行代码(从PowerPoint):

  • 在演示文稿中循环播放每一张幻灯片。
  • 检查每个形状以确定它是否是图表。
  • 如果是图表,请激活底层的Excel工作表,然后将此底层文件中的链接更改为新的源代码。

我注意到到excel的链接并不存在于整个PPT级别[通过Info ],它们被故意链接到每个图表,以便可以在不访问源excel文件的情况下编辑表示

代码工作 – 广泛。

有一个正在进行的错误( 现在代码运行良好 ),我认为去networking和内存的稳定性(约15图表后失败),我正在closures屏幕更新closures屏幕更新为Powerpoint 。

我访问的所有图表都链接到其他工作簿。 然而,当Excel工作簿暴露给PowerPoint时,即使代码处理每个链接, Linksources也不会显示在Locals窗口中(下图显示链接存在)

我翻转自动化从Excel访问PowerPoint包,相同的结果。 没有Linksources

为什么当使用Excel自动化PowerPoint时,在“ 本地”窗口中不能使用完整的对象模型?

这是我偶然发现的一个本地化故障,还是更广泛的问题?

下图显示了通过链接进行迭代的代码( pplvariables,但是xlWBvariables没有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 

当地人和监视窗口显示对象的属性。 Workbook对象的属性列表可以在这里find。

LinkSources是一个可选的Type参数的方法。

如果你想debuggingLinkSources你可以把它添加到Watch窗口中: 在这里输入图像说明

或者将返回值保存到本地variablesvariables中以在“本地”窗口中查看。