Welcome to the PlusCommunity forums! PlusCommunity is a gathering place for companies running Simply Accounting, ACCPAC Plus, Sage Accpac ERP(ACCPAC Advantage/ACCPAC for Windows), and Adagio Accounting. New visitors, please click here!
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" )
If Err.Number <> 0 Then dim strhost strhost = WScript.Arguments.Item(0)
Set objMessage = CreateObject("CDO.Message") with objMessage .From = "email@example.com" .To = "firstname.lastname@example.org;email@example.com" ' .Cc = "firstname.lastname@example.org;email@example.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 .Update end with 'send mail objMessage.Send