'Run-time error '1004': Method 'GetOpenFilename' of object '_Application' failed' on MacOs

Copper Contributor

Greetings!

 

I'm writing some VBA code for selecting a specified file in order to retrieve info from it and paste into destination. I use GetOpenFilename method, however on running I get the above mentioned error 'Run-time error '1004': Method 'GetOpenFilename' of object '_Application' failed'.

 

Here is my code:

 

Sub importData()
    Dim fileToOpen As Variant
    Dim wbImportFile As Workbook
    fileToOpen = Application.GetOpenFilename(Title:="Specify folder with source file", filefilter:="Excel Files(*.xls*), *xls*")

    If fileToOpen <> False Then
        Set wbImportFile = Workbooks.Open(fileToOpen)
        wbImportFile.Worksheets("Sheet1").Range("C3:M4").Copy
        ThisWorkbook.Worksheets("Sheet1").Range("B3").PasteSpecial (xlPasteAll)
    End If
    
End Sub

 

It seems like this parameter causes an error "filefilter:="Excel Files(*.xls*), *xls*". This problem happens only on Mac. There is no problems with Windows version of Excel.

 

Do you know when Microsoft will fix this?

Thanks.

 

 

2 Replies

I have the same problem, I had to run Excel in a Windows VM on my MAC to solve it..... there're other problems too with Excel for MacOS, data segmentation problems...

@VSachenok 

 

I've never worked with a mac, but, according to this, it appears that functionality requires some apple script. Sorry I can't be of more help than this.

 

https://docs.microsoft.com/en-us/previous-versions/office/developer/office-2010/hh710200(v=office.14...