Saving Excel Add-In in Windows 7

12,770

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).

Share:
12,770
OfficeAddinDev
Author by

OfficeAddinDev

Updated on June 04, 2022

Comments

  • OfficeAddinDev
    OfficeAddinDev almost 2 years

    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?

  • OfficeAddinDev
    OfficeAddinDev about 14 years
    I think you're correct about the UAC. I checked out the links, but didn't find anything that helps me around this problem. My add-in file is actually located in a Trusted Location used by Excel, not the Program Files directory. I have to believe that there are other add-ins written in VBA that have encountered this problem...
  • Ant
    Ant about 14 years
    Are you able to save inside the user folder (%appdata%)? If your Trusted Location is not in Program Files, but still in one of the restricted places you'll still have problems. If this is just for development, you can run Excel using right click->'Run as Administrator', which will let you save where you want.
  • OfficeAddinDev
    OfficeAddinDev about 14 years
    Ant, you're right on the money. The add-in must be saved to C:\Users\[User Name]\AppData\Roaming\Microsoft\Addins, or you can use a Trusted Location path if logged in under a UAC. Thanks so much for your help.