I have Word 2016 VBA code to read data in an Excel document.
This works on Windows platforms (Windows 7 and Windows 10).
On Mac it fails on the CreateObject("Excel.Application")
instruction.
run-time error '-2146959355 (80080005)'
Automation error
Is this a problem in Office 2016 for Mac (currently using version 16.23), or is this a problem in my "environment" and the way Office is installed on my Mac?
It used to work and stopped working with an Office 2016 for Mac update. I can not remember which version caused the issue. Since almost two years, I check this code with every Office update and it has always failed.
I tried running a Windows 10 virtual machine with Parallels Desktop, and in this virtual Windows environment, the code works. I need to run it "natively".
The following code reproduces the problem:
Sub MyTestOfCreateObject()
Dim xlapp As Object
Set xlapp = CreateObject("Excel.Application")
xlapp.Visible = True
xlapp.Quit
Set xlapp = Nothing
End Sub
I tried replacing CreateObject("Excel.Application")
with
Set xlapp = New Excel.Application
. I got the same error message.
I expect xlapp to be used as an Excel object.