我正在尝试根据来自其他多个Powerpoint的现有幻灯片创建新的演示文稿。基本上,我有一个模板,然后遍历并插入其他演示文稿中的正确幻灯片。但是,我的代码有时有效,有时无效。
通常错误是462,我相信它与不合格的引用有关(我将同时打开2-3个百分点)?当我尝试设置演示文稿时,第二个循环中代码失败的部分的代码摘录如下(失败行以粗体显示)。 任何帮助表示赞赏。谢谢!
For k = LBound(crncy) To UBound(crncy)
For m = LBound(profile) To UBound(profile)
If (mandateTitles((profile(m)), (crncy(k))) <> "") Then
Set oPres = PowerPointApp.Presentations.Open(templateAddress(i), msoFalse)
Set perfPres = PowerPointApp.Presentations.Open((performanceSlideDeck(i)),
msoFalse)
For j = 1 To perfPres.Slides.count Step 1
oPres.Slides.InsertFromFile (perfPres.path & "\" & perfPres.name), 14, j, j
'''''insert portfolio slides''''''''
sFileName = findPreso((contentSlidesFolder & "\"), (profile(m)), (crncy(k)), (lang(i)))
**Set contentPres = PowerPointApp.Presentations.Open((sFileName), msoFalse)**
...
next j
next m
next k