Select files on a Mac (GetOpenFilename)
Below are the steps to create your Personal Macro Workbook in the MAC version of the Excel. First of all, go to the developer tab and click on the “Record Macro Button”. After that, enter the name of the macro and select the “Personal Macro Workbook” from the drop-down. I have a complex.xlsb file with many macros, pivot tables, VBA function, external sql connections, controls. My managers would like this file to be runnable on a Mac. I've searched EE and i-net. The conventional wisdom appears to be that Excel and macros can run on a Mac. I have created a Personal.XLSB file for Excel Macros here on my Mac, however I cannot open this file and thus cannot edit macros in it. Searches of the web only turn up Windows instructions to 'Unhide' this workbook, but the command to do so does not seem to be in the View or Developer Tabs of Excel (and cannot be added via editing the Ribbon via Preferences; what am I missing.
In Windows we can use for example GetOpenFilename to select files and do what we want with the path results, you can use filefilter to only display the files you want and use MultiSelect to select more then one file. Also it is possible with ChDrive and ChDir to set the folder that is selected when GetOpenFilename opens, see a example on the bottom of this page for Excel for Windows.
But on a Mac the filefilter is not working and it is not possible to select more then one file. Also ChDir is not working like in Windows to set the folder that will open with GetOpenFilename. But we can use a combination of VBA and Applescript, see example below that only let you select xlsx files and you can set the start folder.
Important : The file location can be very important in Mac Excel 2016, read : Problems with Apple’s sandbox requirements in Mac Office 2016 and higher with VBA code
Xlsb Open On Mac
Example for Mac Excel 2011 and 2016 and higher
Note : Do not forget to copy the bIsBookOpen function below the macro.
You can run the macro below without changing it, it opens the Desktop in the file select dialog and you can only select one xlsx file now, see the code how to change this.
Note : If you got problems with the code please report it to me so i can fix it.
Other file formats are :
In the macro you see this code line that say which file format you can select (xlsx).
FileFormat = '{'org.openxmlformats.spreadsheetml.sheet'}'
If you want more then one format you can use this to be able to also select xls files.
Xlsb Mac
FileFormat = '{'org.openxmlformats.spreadsheetml.sheet','com.microsoft.Excel.xls'}'
This is a list of a few formats that you can use :
xls : com.microsoft.Excel.xls
xlsx : org.openxmlformats.spreadsheetml.sheet
xlsm : org.openxmlformats.spreadsheetml.sheet.macroenabled
xlsb : com.microsoft.Excel.sheet.binary.macroenabled
csv : public.comma-separated-values-text
![Xlsb Xlsb](https://excelchamps.com/wp-content/uploads/2019/01/to-create-personal-xlsb-macro-workbook-in-excel-mac-click-record-macro.png)
doc : com.microsoft.word.doc
How To Open Xlsb On Mac
docx : org.openxmlformats.wordprocessingml.document Pdf annotator mac.
docm : org.openxmlformats.wordprocessingml.document.macroenabled
ppt : com.microsoft.powerpoint.ppt
pptx : org.openxmlformats.presentationml.presentation
pptm : org.openxmlformats.presentationml.presentation.macroenabled
Xlsb Macro
txt : public.plain-text
pdf : com.adobe.pdf
jpg : public.jpeg
png : public.png
QIF : com.apple.traditional-mac-plain-text
htm : public.html
If you need to know another format send me a mail and I try to help you.
Example for Excel for Windows
Note: The macro example for Windows and Mac are both using this function to test if the file is open.
In Windows you can use filefilter to only display the files you want and use MultiSelect to select more then one file. Also it is possible with ChDrive and ChDir to set the folder that is selected when GetOpenFilename opens, see basic Windows example below :
When you want to add more filters you can use this in the Windows macro to filter on xls and csv files