Link to home
Start Free TrialLog in
Avatar of dearnemo
dearnemo

asked on

SQL Job doesn't run vbs Script file

In reference to this thread: https://www.experts-exchange.com/questions/27727445/vbScript-to-add-modules-to-excel-file.html?anchorAnswerId=37999278#a37999278

Now I tried to run my vbs script from SQL Job. Though I get Job executed successfully, it didn't open up my excel file. I went to view the history for this job and found

Message
Executed as user: GSOPS4\SYSTEM. Microsoft (R) Windows Script Host Version 5.7  Copyright (C) Microsoft Corporation. All rights reserved.C:\WINDOWS\system32\TestTOPTMay307.vbs(5, 1) Microsoft Excel: Microsoft Excel cannot access the file '\\gsops4\data_extracts\TestTOPTMay307.xlsm'. 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.  Process Exit Code 0.  The step succeeded.

Any thoughts?
Avatar of ukerandi
ukerandi
Flag of United Kingdom of Great Britain and Northern Ireland image

try this
Under component services > Computers > My Computer > DCOM Config + Microsoft Excel application > properties > Identity Tab > Select the Interactive User > Ok.

 

You'll also what to add this to the bottom of your script so Excel closes and does not hang around in the background.

$excel.Quit()
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($excel)

http://technet.microsoft.com/en-us/library/ff730962.aspx
ASKER CERTIFIED SOLUTION
Avatar of ukerandi
ukerandi
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial