I have a VBScript that errors when I try to get Excel's status bar string. See comments in code below. I tried putting objExcel.DisplayStatusBar = True in above the erroneous line, but then that line errors. That tells me something about objExcel is going wrong(?). If I put in a msgbox just prior to the erroneous line, it hangs the entire vbs (expected). This vbs runs in the morning so when I see the msgbox popup and click OK all systems have already completed except the vbs that is hanging because of the msgbox. I click OK on the msgbox and I get no error. The reason I am waiting with a timed loop is because macro CreateModel has some Application.OnTime calls in it back to CreateModel, which is necessary for reasons that are beyond this question. The VBScript doesn't 'know' that I have OnTime calls so if I don't 'wait' it will proceed with the rest of the vbs code and mess things up for other reasons. So I have to wait and I use the statusbar to know when all is finished. I can't do a purely timed wait because the processing time of CreateModel and its associated OnTime calls varies quite a bit.
It is a little confusing. Looking for debug suggestions and/or solutions if you have any.
EDIT: if someone knows how to create the error "call rejected by callee" for line sStatus = objExcel.StatusBar, that would help me debug this.
EDIT2: Here is a picture of the error. The script is a .vbs file. I had to grey out the path for my clients protection:
VBScript:
Dim objExcel, wMn, r, wT
Set objExcel = CreateObject("Excel.Application")
Set wMn = objExcel.Workbooks.Open("Z:\path\Model_*.xlsm")
objExcel.Application.Visible = True
objExcel.Run "'Z:\path\" & wMn.Name & "'!CreateModel"
'wait until model is finished
'have to do this because Application.OnTime is called in CreateModel and vbs doesn't wait
Dim sStatus
Dim dteWait
Do
dteWait = DateAdd("s", 600, Now()) '60 = 60 secs, 600 = 10 mins
Do Until (Now() > dteWait)
Loop
'objExcel.DisplayStatusBar = True '<-- if I include this line I get the same error, but for this line
'msgbox objExcel.StatusBar '<-- when I include this line no error occurs, see notes at top
sStatus = objExcel.StatusBar '<-- main error/issue
Loop While not sStatus = "Model Finished"
'more code below, but omitted for clarity