我正在尝试在Word中打开Excel文件以读取某些单元格的值,并对Word中的新文件做一些魔术。
我使用Microsoft Windows做过很多次了。现在,我无法使用Windows,必须使用我的私人计算机,使用我在Mac上编写的文件时遇到了一些问题。
我在两个OS:Office Word 2016上使用了相同的版本,但是在Mac中运行宏时遇到错误。
我正在
代码为-2146959355(80080005)的运行时错误。
该代码是巨大的,但我尝试剥离以查找错误。不用说,我已经达到了剥离更多等于删除宏的地步。因此,这是给我错误的代码。而且我不明白原因。
Sub AutoOpen()
Dim objExcel As New Excel.Application
Dim exWb As Excel.Workbook
Dim excelFile As String
excelFile = ActiveDocument.Path & Application.PathSeparator & "file.xlsx"
If (Dir(excelFile) <> "") Then
Set exWb = objExcel.Workbooks.Open(excelFile)
exWb.Close
Else
MsgBox ("File not found")
End If
End Sub
The error is referring to the Set of exWb
相同的代码在Windows中工作