Is there a universal OS variant of this? I am looking to have this code work on a Mac and PC, but this seems only to work on a PC.
strFile = Application.GetOpenFilename("Text Files (.csv),.csv", , "Please selec text file...")
Is there a universal OS variant of this? I am looking to have this code work on a Mac and PC, but this seems only to work on a PC.
strFile = Application.GetOpenFilename("Text Files (.csv),.csv", , "Please selec text file...")
Check out the solution on MSDN - Programmatically Selecting Files in Excel for Windows and Excel for the Mac
I find that I am able to use
Application.GetSaveAsFileName
on both PC and Mac without issue.However I also found that
Application.GetOpenFilename
does not work on the Mac, so I did some googling and came up with this function as a workaround on the Mac:Here is the implementation of
Select_File_Or_Files_Mac
:I hope this helps!
It works in MAC (Excel 2011) As well. See screen shot
FOLLOWUP Upon discussion in chat as I suspected the error was not with
Application.GetSaveAsFilename
but something else. In this case it wasApplication.GetOpenFilename
Now
Application.GetOpenFilename
definitely gives a problem in Mac. I would recommend seeing this thread which also addresses your problem.Error when closing an opened workbook in VBA Userform