Forum Discussion

VSachenok's avatar
VSachenok
Copper Contributor
Jan 19, 2022

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

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

Resources