I've written a vbs that essentially opens Excel in the background, runs a macro on it and then saves it by appending the value of a cell to it's name. However, and this only occurs sometimes, I get a error on the bolded lines...
Line: 23
Char: 3
Error: Call was rejected by callee.
Code: 80010001
Source: (null)
Option Explicit
ExcelMacroExample
Sub ExcelMacroExample()
Dim objExcel
Dim objApp
Dim objWorkbook
Dim objSheet
Dim SI
Dim scriptdir
Dim oFSO
Set oFSO = CreateObject("Scripting.FileSystemObject")
scriptdir = oFSO.GetParentFolderName(WScript.ScriptFullName)
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open(scriptdir & "\SCORECARD.xlsm")
objExcel.Run "RefreshConns"
WScript.Sleep 90000
Set objSheet = objWorkbook.Worksheets("Cover")
SI = objSheet.Cells(4, 2).Value
objExcel.ActiveWorkbook.SaveAs scriptdir & "\Scorecards\" & "SCORECARD_" & SI & "_" & Year(Now()) & Month(Now()) & Day(Now()) & "_" & Hour(Now()) & Minute(Now()) &".xlsm", 52
objExcel.ActiveWorkbook.Close
objExcel.Quit
MsgBox("Successfully generated profiling scorecard.")
End Sub