Yes, before you say anything, Excel Interop isn’t something you should be doing, unless you have to.
Anyway, typical problem is this: you create some C# code that uses Excel Interop to do the ugly things that you are doing, and all works fine. Then, you try to schedule it through Windows Scheduler or SQL Server Agent or run the code from a web site in IIS, and each time you try to run it, it throws this error.
From Bob Templeton in the MSDN forums’ post here, you need to do this:
- Create the directory "C:\Windows\SysWOW64\config\systemprofile\Desktop " (for 64 bit Windows) or "C:\Windows\System32\config\systemprofile\Desktop " (for 32 bit Windows)
- set the permissions required on that directory (so, if using IIS, you would want to grant full permissions to the AppPool in question, with SQL Server Agent, to whatever login it is running under, etc.).
Even though I am running Windows 7 64, I had to create the directory under “System32” to get passed this error.
But really, that’s all you have to do. Create a folder.
If you do these things and still get this error, Google for another solution.