下午好,
我正在运行一个非常简单的脚本,该脚本应将一个主要的Excel工作簿与另一个Excel工作簿和一个MSProject文件连接。 一旦运行它,宏就会冻结,并开始吐出以下错误“ Microsoft Excel正在等待另一个应用程序完成OLE操作”。
有人知道怎么回事吗?
我正在使用的脚本如下:
Sub trial()
Dim wbPac As Workbook
Dim wb1 As Workbook
Set wb1 = ActiveWorkbook
' CREATING AND SAVING THE EXCEL WORKBOOK
Set wbPac = Workbooks.Add
Dim xlsxFileSaveName As String
xlsxFileSaveName = "Sample_name"
wbPac.SaveAs Filename:="C:\" & xlsxFileSaveName ' address where I save the external Excel workbook
' OPENING MS PROJECT FILE
Dim proj As MSProject.Application
Dim FileOpenType As Variant
Set proj = New MSProject.Application
FileOpenType = Application.GetOpenFilename( _
FileFilter:="MS Project Files (*.mpp), *.mpp", _
Title:="Select MS Project file", _
MultiSelect:=False)
proj.FileOpen FileOpenType