I have a workbook that I am trying to get to work on both the Windows & Mac versions of Excel. So far so good on Windows. I'm having a problem on Excel 2011 for Mac right now, and can't seem to figure out why. Google searching has not turned up a solution.
One of the things my workbook does is it creates a new workbook, and I want to save that new workbook to a specific folder on the Mac. That folder (on my Mac) is:
El Capitan:mattc:Library:Containers:com.microsoft.Excel:Data:Test Folder:
All of those folders exist. In fact, my code will create the "Test Folder" folder if it does not already exist.
My code will create the new workbook, but when it tries to save it, I run into the problem. The line of code causing the error is:
For the sake of my testing, here is what the variables are:
FileNameAndPath = "El Capitan:mattc:Library:Containers:com.microsoft.Excel:Data:Test Folder:TestFile.xlsx"
FilePassword = "password2019"
On Excel 2019 for Mac, this works perfectly. On Excel 2011, I am getting this error:
Run-time error '1004':
Microsoft Excel cannot access the file 'El Capitan:mattc:Library:Containers:com.microsoft.Excel:Data:Test Folder:88544000'. There are several possible reasons:
- The file name or path name does not exist.
- The file you're trying to open is being used by another program. Close the document in the other program, and try again.
- The name of the workbook you're trying to save is the same as the name of another document that is read-only. Try saving the workbook with a different name.
I remember seeing this error once before on Windows, when I was trying to write a file inside the "Program Files" folder. I assumed I did not have permission to access that folder. But I don't understand why I would not have permission to access the folder in question here, especially when it works fine in Excel 2019.
I know that it is possible for Excel VBA to write a file to this particular folder on Mac, because I have a workbook (not created by me) that does it. Unfortunately, the code on that workbook is password-protected, so I can't see how they do it.
Anyone have any ideas what might be wrong?
Bookmarks