SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Open Excel Error Using PowerShell in SQL Server Agent Job


Open Excel Error Using PowerShell in SQL Server Agent Job

Author
Message
Lrobinson 93181
Lrobinson 93181
Valued Member
Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)

Group: General Forum Members
Points: 65 Visits: 140
Ok, I now see that the "Desktop" file workaround fixes a "save as" exception, and my exception occurs when opening the Excel file. I am going to convert my excel to csv and see if that cures the problem.
Thank you for all of your help!
MickyD
MickyD
SSC-Addicted
SSC-Addicted (448 reputation)SSC-Addicted (448 reputation)SSC-Addicted (448 reputation)SSC-Addicted (448 reputation)SSC-Addicted (448 reputation)SSC-Addicted (448 reputation)SSC-Addicted (448 reputation)SSC-Addicted (448 reputation)

Group: General Forum Members
Points: 448 Visits: 1499
Lrobinson 93181 (6/18/2013)
Ok, I now see that the "Desktop" file workaround fixes a "save as" exception, and my exception occurs when opening the Excel file. I am going to convert my excel to csv and see if that cures the problem.
Thank you for all of your help!


Hi , did you find a way to fix this ?
I am getting exactly the same error as

"Exception calling "SaveAs" with "1" argument(s):"SaveAs method of Workbook class failed"
The script runs fine outside of job agent, it creates an excel workbook, adds data to cells, saves, and closes.
-- My script also runs fine outside of an SQL agent job
-- Also tried the create Desktop folder option as listed earlier
I am not sure what this means, although it consistently fails to complete the script (for different reasons), it does appear to run the script
-- Same for me.

Appreciate any thing you found that made it work ?

cheers
Lrobinson 93181
Lrobinson 93181
Valued Member
Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)

Group: General Forum Members
Points: 65 Visits: 140
Hi, I was not able to make it work from my system, however I did get it to work properly by putting the desktop file on the server where the database resides. I also installed the redistributable http://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=13255 on that server, after making sure Office was installed there as well.

The job now works as scheduled, but if I try to run it manually from my system I still get the same "opening Excel" error.

Good luck, I know it took a long time and a lot of trial and error for me to find the solution that worked for me. Just keep applying all the suggestions everyone has made and eventually one of them will fit.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search