I am trying to open an Excel file in Word to read the values of some cells and do some magic to a new file in word.
A thing that I did many times using Microsoft Windows. Now that I’m unable to use Windows and I have to use my private computer I am facing some issues to use the files that I wrote on my Mac.
I am using the same version on both O.Ss.: Office Word 2016 but I am getting an error when I run the macro in my mac.
I am getting a
Runtime-Error with code -2146959355 (80080005).
The code is huge but I tried stripping down to find the error. Needless to say that I’ve reached the point that stripping more is equals to removing the macro. So, this is the code that is giving me the error. And I can’t understand the reason.
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
This same code is working in Windows