I have an Excel add-in I am developing that works fine in Windows XP. However, I just got a hold of Windows 7 Professional and now I cannot save this add-in, either manually from the VBA Editor or programmatically using ThisWorkbook.Save
.
The error message says
"Micrsosoft Office Excel cannot access the file 'C:\Program Files\Microsoft Office\Office 12\LIBRARY[some random 8-character string rather than the name of my add-in]".
One of this dialog error's possible explanations is that "The file name or path does not exist". Well, of course it doesn't.
I tried turning off read-only on the add-in file and its directory, as well as "Unblocking" the file (seems to be a new Windows 7 feature) using the Properties dialogs, but to no avail.
How do I get this basic save functionality to work in Windows 7?
I'm guessing this is the UAC behaviour of Windows that was introduced in Vista, and is still in Windows 7.
Have a look at this Microsoft page for a user perspective, and this MSDN one for an idea of how to program with it in mind.
In summary, you can't write to Program Files without asking for elevation if you have UAC on.
(Edit: couple of extra points raised by the comments) If this is just for development, you can run Excel using right click->'Run as Administrator', which will let you save where you want, or you can save in %AppData%\Microsoft\Addins, which is also a trusted location (see this MSDN article for more details of that).