如何在不自动更新链接的情况下从 Excel VBA 宏打开 PPT 文件?

问题描述 投票:0回答:0

我有一个 OLE 问题。我编写了运行 Excel 宏的 VBA 代码来更新 PowerPoint 演示文稿中 Excel 对象的链接。问题是当正在更新的 PPT 文件包含指向位于同一目录但未打开的另一个 Excel 文件的链接时,更新速度非常慢(需要几分钟 - 有时多达 30 分钟)。这种情况会导致 PPT 打开时浪费几分钟的时间来打开和关闭旧的 Excel 文件以刷新链接,然后新的 Excel 宏会接管并通过所有链接。当文件不更新链接时,它会在 1-2 分钟内运行。我想做的是修改首先打开 PPT 文件的代码,使其在不更新 OLE 链接的情况下打开。

我要修改的代码在下面的粗体中:

私有函数 OpenPresentation(sFileName As String) As Object

If sFileName <> "" Then
    If moPowerPointApp Is Nothing Then ' only create one PowerPoint Instance to save memory
        Set moPowerPointApp = CreateObject("PowerPoint.Application")
    End If
        
    **Set OpenPresentation = moPowerPointApp.Presentations.Open(sFileName)** 'open the powerpoint
    
    If OpenPresentation Is Nothing Then ' if it didn't open, show a message
        MsgBox "Unable to Open the specified PowerPoint file"
    End If
End If

结束功能

我尝试使用修饰符 (updateslinks:=0) 我看到 unline 不在 Excel 中自动更新链接(如下),但这不起作用。我假设这是因为打开的文件是 PPT,而不是 Excel 文件。我想找到一个类似的修改器,我可以使用这样当我打开 PPT 文件时,链接不会更新。

Workbooks.Open Filename:=arrFiles(i), updatelinks:=0

excel vba ole powerpoint-2016
© www.soinside.com 2019 - 2024. All rights reserved.