PDA

View Full Version : Cannot edit an Excel worksheet from scheduled task


teognost
07-05-2012, 11:46 AM
I am trying to edit an Excel worksheet using the sample provided here:
http://kinook.com/Forum/showthread.php?t=500&highlight=Excel.Application
with small changes (attached is the bld and excel file).
When trying to run this bld file -both tom VBP and from a scheduled task -all works ok from my machine (WinXP X86,VBP 8.0 X86,MS Office 2007).
When I try it from another build machine -W2k8 R2 X64,VBP 8.0 X64,MS Office 2010 -it works ok from VBP environment,the log says:

7/5/2012 6:44:36 PM: Building project step 'mod worksheet'...
xlApp object is NOT empty!
xlBook object is NOT empty!
xlSheet object is NOT empty!
Cell 1,1 has value:1000
7/5/2012 6:44:36 PM: Build successfully completed (elapsed = 00:00:00).

But when running this build from a scheduled task -never works.
Log says:
7/5/2012 6:44:06 PM: Building project step 'mod worksheet'...
xlApp object is NOT empty!
xlBook object is empty!!!
xlSheet object is empty!!!
7/5/2012 6:44:06 PM: Build successfully completed (elapsed = 00:00:00).

So I would like to ask you what could be the problem causing this bld project not to work from a scheduled task (basically for some reason xlBook and xlSheet are empty objects )...

kinook
07-05-2012, 12:24 PM
Not sure, but you can reproduce the problem outside of Visual Build by putting the script code in a .vbs file and calling via cscript.exe in a scheduled task.

teognost
07-06-2012, 07:29 AM
i tried that ,made a VBScript (attached) -it runs ok when launched normally (objects are not empty) ,does not work from scheduled task (objects are empty)
So it is the same behaviour like in VBP.Question is why ...

kinook
07-06-2012, 07:32 AM
Ask Microsoft.

teognost
07-06-2012, 07:47 AM
ok,I will.Tks.

teognost
07-06-2012, 09:33 AM
After a lot of search I founded a resolution for this problem.
After I created manually the Desktop folder -sch task finished ok.

http://blogs.msdn.com/b/sqlserverfaq/archive/2010/04/30/unable-to-open-excel-files-using-a-cscript-in-sql-server-jobs.aspx

Resolution
************
· A “Desktop” folder seems to be necessary in the “systemprofile” folder in the location C:\Windows\SysWOW64\config\ to open an Excel file
· Create the “Desktop” folder for Windows 2008 Server (x64) under the location C:\Windows\SysWOW64\config\systemprofile
· And for a 32 bit Windows 2008 Server create the “Desktop” folder under the location C:\Windows\System32\config\systemprofile