Using the dir and macid functions in Excel 2011 VBA


I came across the dir() and macid() functions in Excel 2011 on the Mac OS X 10.6.8 when I was converting my sitemap generator from Excel 2013 VBA to work on the Mac in Excel 2011 VBA. File types in Windows parlance are defined by the last characters in the file name for example .TXT or .DOCX. On Mac OSX the file type is a specific Linux attribute of the file (?) Here is the MSDN write up of the dir() function which apparently has a second attribute parameter even on a Windows machine although most programmers would use a wildcard in the directory specification to select a subset of the directory contents for example *.txt to select all the files with the .txt extension. To replicate this behaviour on a Mac the macid() function is required. Here is the MSDN write up of the macid() function which uses the file attribute to achieve roughly the same effect. This attribute is not set for files that were originated on a Windows machine and for files created with Office for the Mac there are various file types that can be tested for although I can find no enumeration of all the different types that could be set.



Tags - Excel for Mac 2011, VBA, code, Microsoft, Visual BASIC for Applications, dir(), macid(), MSDN, file attribute, directory contents, file types, enumeration ...