Check if File or Folder exists on Mac
Note : When you use VBA in Mac Excel 2016 or higher that is working with files and folders you will notice that it is possible that it will ask you permission to access the file or folder (Grant File Access Prompt), this is because of Apple’s sandbox requirements.This means that when you want to save/open files or check if it exists with VBA code the first time you will be prompted to allow access on the first attempt to access such a folder or file. If you want to avoid problems like this use the AppleScriptTask example on this page or read the info on this page: Problems with Apple’s sandbox requirements
Use VBA Dir to check if a file or Folder exists
I have decided to remove the samples for testing whether a file or a directory exists with VBA Dir from this page. Unfortunately, there are still problems with Dir that cannot be solved at the moment. The advantage of using the AppleScriptTask example on this page is that it will not ask you permission to access the file or folder (Grant File Access Prompt). I hope there will be a solution for the problems with VBA Dir soon so that I can share examples on this page again.
Use AppleScriptTask to check if a file or Folder exists
With the AppleScriptTask method you need to distribute an extra file containing the script, and it must be placed in the specified location on the user’s system to have permission to run. This requires some user interaction the first time.
I create this install script for you to copy the script file in the correct location, you can download the Install.scpt script together with the FileFolder.scpt file below. The folder must be in the Users Download folder, you see that if you download the compressed folder from my website it will automatically uncompressed in your Downloads folder and you can double-click the Install.scpt file in it to Open and Run it to copy the FileFolder.scpt in the correct location so the AppleScriptTask function can find it. The advantage of using the AppleScriptTask example is that it will not ask you permission to access the file or folder (Grant File Access Prompt).
You can download the Install.scpt and FileFolder.scpt files below (File dates 4-Dec-24)
Download Files
I create this install script for you to copy the script file in the correct location, you can download the Install.scpt script together with the FileFolder.scpt file below. The folder must be in the Users Download folder, you see that if you download the compressed folder from my website it will automatically uncompressed in your Downloads folder and you can double-click the Install.scpt file in it to Open and Run it to copy the FileFolder.scpt in the correct location so the AppleScriptTask function can find it. The advantage of using the AppleScriptTask example is that it will not ask you permission to access the file or folder (Grant File Access Prompt).
You can download the Install.scpt and FileFolder.scpt files below (File dates 4-Dec-24)
Download Files