I have a problem with starting the Excel Application under a particular user.
I try to schedule this script (C#) through an application X (not Windows Task Scheduler). If I run the script in command prompt under the same user, it runs. But not under the application X (using the exact same user to initiate the script.
This script calls: app.Workbooks.Open(ExcelFileName,0,false,Type.missing....), yet it gives the following error:
Microsoft Excel cannot access the file "...". There are several possible reasons:
-The file name or path does not exist.
-The file is being used by another program.
-The workbook you are trying to save has the same name as a currently open workbook.
I tried all the methods that I found online to no avail.
- Create directory “C:\Windows\SysWOW64\config\systemprofile\Desktop” (for 64 bit Windows) or “C:\Windows\System32\config\systemprofile\Desktop” (for 32 bit Windows). Then Set full control permissions on Desktop directory above (for example in Win7 & IIS 7 & DefaultAppPool set permissions for user “IIS AppPool\DefaultAppPool”)
- Changed the DCOM config for the Microsoft Excel application to include this user for Local/Remote Launch and Access
- Enabled all macros in Excel and set the Trust Center.
- Add the user to have full control on all folders that contain the Excel file.
- Under DCOM config, Microsoft Excel Application, if I modify the Identity tab and check on "This User" and enter the username/password for this user. Then this Excel report runs fine with no problem. However, this will default Excel to always run under that user even though another user logs in and runs Excel?
Yet, still the same error. I think it's permission but I am not sure where and what to do for this to work.
Now, normally, when I run this excel report, I can double-click on the file and it'd automatically run, save the new parameters into the current file and generate a new excel file (with date attached to the file name). That means there is a change (save) to the original file.
I appreciate all your help!
Aucun commentaire:
Enregistrer un commentaire