(Solved) – Runtime errors when trying to open Word document from Excel VBA on Mac OS


First post here but a long time lurker. Frequently I write Excel macros to manipulate Word documents, however I’m trying to write one now on a Mac and I get runtime errors in the very first step when trying to open the file.

Sub OpenWord()

Dim w As Object
' If word is already open get ahold of the running instance
' Otherwise create a new instance
On Error Resume Next
Set w = GetObject(, "Word.Application")
If w Is Nothing Then Set w = CreateObject("Word.Application")
On Error GoTo 0
' Close all open files and shutdown Word
' Loop through any open documents and close them
Do Until w.Documents.Count = 0
w.Quit False
Set w = Nothing

' Now that all instances of word are closed, open the template
Dim wdApp As Object
Dim wdDoc As Object
Set wdApp = CreateObject("Word.application")
wdApp.Visible = True
wdApp.DisplayAlerts = False
Set wdDoc = wdApp.Documents.Open(FileName:="https://stackoverflow.com/myfile.docx")

End Sub

And when running I get: “Run-time error: ‘-2146959355 (80080005)’:”

Any ideas what might be happening?


Leave a Reply

Your email address will not be published. Required fields are marked *