mattshoreson
Programmer
Ok here goes, the basic architecture is as follows:
scheduler has a batch file with looks for an errorlevel of 0 or 1.
Batch file calls a vbs file.
vbs file runs a sql server stored procedure to place a file in a specified directory for subsequent pull of an ftp job.
Code for vbs files is as follows:
Option Explicit
Dim filePath, oExcel
Dim strComputer, objWMIService, colProcessList, objProcess
filePath = "C:\WINDOWS\Temp\test.xls"
Set oExcel = CreateObject("Excel.Application")
oExcel.Visible = True
oExcel.Workbooks.Open filePath
oExcel.Run("MyMacro")
oExcel.Quit()
Set oExcel = Nothing
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery ("Select * from Win32_Process " & "Where Name = 'Excel.exe'")
For Each objProcess in colProcessList
objProcess.Terminate()
Next
wscript.Quit()
My question is if an error is generated in the macro in the xls how do I get this value back to the vbs script so I can pass it in the quit command?
Cheers, Matt.
scheduler has a batch file with looks for an errorlevel of 0 or 1.
Batch file calls a vbs file.
vbs file runs a sql server stored procedure to place a file in a specified directory for subsequent pull of an ftp job.
Code for vbs files is as follows:
Option Explicit
Dim filePath, oExcel
Dim strComputer, objWMIService, colProcessList, objProcess
filePath = "C:\WINDOWS\Temp\test.xls"
Set oExcel = CreateObject("Excel.Application")
oExcel.Visible = True
oExcel.Workbooks.Open filePath
oExcel.Run("MyMacro")
oExcel.Quit()
Set oExcel = Nothing
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery ("Select * from Win32_Process " & "Where Name = 'Excel.exe'")
For Each objProcess in colProcessList
objProcess.Terminate()
Next
wscript.Quit()
My question is if an error is generated in the macro in the xls how do I get this value back to the vbs script so I can pass it in the quit command?
Cheers, Matt.