使用VBA将嵌入的OLEObject复制到文件而不打开应用程序

时间:2018-06-10 12:10:04

标签: vba

我有一个带有PPT嵌入的Excel文档。 我想创建一个VBA子程序,将该文件复制到filepath文件夹:

Dim PPTApp As PowerPoint.Application
Set PPTApp = New PowerPoint.Application

Dim Filepath As String
Filepath = ActiveWorkbook.Path

Dim File As PowerPoint.Presentation
' Worksheet(1).OLEObjects(1).Verb xlOpen
Set File = Worksheet(1).OLEObjects.Object
File.SaveAs Filepath & "\ppt.pptx", PowerPoint.ppSaveAsOpenXMLPresentation, msoTriStateMixed

如果我对该行留下评论,我会收到错误:

Run-time error 1004, Unable to get Object Property of OLEObject class

但如果我取消注释,PowerPoint将在保存文件之前启动。

0 个答案:

没有答案