Hi All;

I have written a macro that imports OE Orders. The input data is stored in a csv file. The macro works well and runs well. I have been running the macro for a long time. It is triggered from the Windows Task scheduler. The job runs under its own Windows user id and its own Sage 300 user id.

We have a 2nd location that we want to mimic the same process. We copied the macro and created a new Windows user id and Sage 300 user id. This 2nd macro runs fine from the Windows Task Scheduler as well.

However, we have discovered that if the first macro is running when the 2nd macro starts, we get the following Windows VB Script error:
"Error Number 9 - Subscript out of range".

I think the VBS script is getting hung up on the command:

Set Signon = CreateObject("A4wSignonMgr.AccpacSignonMgr")

Here is the VBS Script that I am using to log into Sage and run the macro:

On Error Resume Next

Dim Signon
Dim SignonID
dim strCommand
Dim wshShell

Set Signon = CreateObject("A4wSignonMgr.AccpacSignonMgr")
Set wshShell = CreateObject( "WScript.Shell" )

SignonID = Signon.RegisterSignon("XXXX", "XXXXX", "XXXDAT", "XXXXXXX", Date)
strCommand = "A4WVBA.EXE -r -f ""c:\Sage\Sage300\Programs\Macros\OE_ORDER_CREATE_TOR-Silent.avb"""

wshshell.run strCommand, 1, True

If Err.Number <> 0 Then
dim strhost
strhost = WScript.Arguments.Item(0)

Set objMessage = CreateObject("CDO.Message")
with objMessage
.From = "xxxx@xxx.ca"
.To = "xxxx@xxx.ca;xxxx@xxxxx.com"
' .Cc = "xxxx@xxx.ca;xxxx@yahoo.com"
.Subject = "PDA_VAN could not start PDA Import Macro"
.TextBody = "PDA VAN import macro did not start." & vbcrlf
.TextBody = .TextBody & " Error Number" & Err.Number & " " & Err.Description
' if WScript.Arguments.Count > 1 then
' .AddAttachment WScript.Arguments.Item(1)
' .TextBody = .TextBody & "Please see the attachment for error info."
' end if
end with

'setup without smtp service on host
' URI is for unique ID not for any access
dim strURI
strURI = "http://schemas.microsoft.com/cdo/configuration/"
with objMessage.Configuration.Fields
.Item (strURI & "sendusing") = 2
.Item (strURI & "smtpserver") = "smtp.xxxx.com"
.Item (strURI & "smtpserverport") = 25
end with
'send mail

End If

Set wshshell = nothing

Signon.SignoffSession SignonID

Set Signon = Nothing
Set SignOnID = Nothing

Any ideas/thoughts are welcome.