Jan 19 2022 01:04 AM
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.
Feb 05 2022 08:22 AM - edited Feb 05 2022 08:24 AM
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...
Feb 05 2022 09:46 AM
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.