Hi Greg,
We are running 4.3. And it is possible, err, well, it works for us at least. Code is below. Pay attention to some of the comments. It does have to run as a user, and that user has to have ran the report at least once from within MAS. We created a user that all it can do is run the report. Hope others can find use for it too. It's all about giving back to the community, right?
Cheers, Ron.
Const HKEY_CURRENT_USER = &H80000001
Set oReg = GetObject("winmgmts:\\.\root\default:StdRegProv")
oReg.GetExpandedStringValue HKEY_CURRENT_USER,"Software\ODBC\ODBC.INI\SOTAMAS90","Directory",PathRoot
PathHome = PathRoot & "\Home"
Set oReg = Nothing
Set oScript = CreateObject ("ProvideX.Script")
oScript.Init(PathHome)
Set oSS = oScript.NewObject("SY_Session")
sUser = "username"
sPassword = "userpass"
sCompanyCode = "companyid"
retVal = oSS.nSetUser(sUser,sPassword)
retVal = oSS.nSetCompany(sCompanyCode)
retVal = oSS.nSetModule("C/M")
retVal = oSS.nSetDate("C/M",oSS.sSystemDate)
retVal = oSS.nSetProgram(oSS.nLookupTask("CM_UDTMaint_UI"))
Set oUDT = oScript.NewObject("CM_UDTMaint_bus",oSS,"SO_UDT_SO_PRINTING_FORM_TYPES")
retVal = oSS.nSetModule("S/O")
retVal = oSS.nSetDate("S/O",oSS.sSystemDate)
retVal = oSS.nSetProgram(oSS.nLookupTask("SO_SalesOrder_UI"))
Set oSO = oScript.NewObject("SO_SalesOrder_bus", oSS)
retval = oSS.nSetProgram(oSS.nLookupTask("SO_SalesOrderQuickPrint_UI"))
Set soPrint = oScript.NewObject("SO_SalesOrderPrinting_rpt", oSS)
retVal = oSO.nMoveFirst()
Do Until oSO.nEOF = 1
printOrder = "N"
' soType - Sales Order Form Type Values
' "1" = ORM-D
' "2" = Must Ship Today - NOT USED
' "3" = Next Day Air
' "4" = Next Day Saturday
' "5" = Second Day Air
' "6" = Three Day select
' "7" = Backorder - NOT USED
' "8" = Regular
soType = "8"
soNum = ""
retVal = oSO.nGetValue("SalesOrderNo$",soNum)
if Left(soNum,1)="W" then
printSO = ""
retVal = oSO.nGetValue("PrintSalesOrders$",printSO)
if printSO = "Y" then
printOrder = "Y"
shipVia = ""
retVal = oSO.nGetValue("ShipVia$",shipVia)
Select Case shipVia
Case "UPS - NDA","UPS - NDA EARLY","UPS - NDA SAVER"
soType = "3"
Case "UPS NEXTDAY SAT"
soType = "4"
Case "UPS - BLUE","UPS - BLUE AM"
soType = "5"
Case "UPS - THREE DAY"
soType = "6"
End Select
Set oItemSvc = oS

Lines.oGetChildHandle("ItemCode")
retVal = oS

Lines.nMoveFirst()
Do Until oS

Lines.nEOF = 1
itemCode = ""
retVal = oS

Lines.nGetValue("ItemCode$",itemCode)
itemCat1 = ""
retVal = oItemSvc.nGetValue("Category1$",itemCat1)
if itemCat1 = "ORM-D" then
soType = "1"
end if
retVal = oS

Lines.nMoveNext()
Loop
' Write record to UDT table
retVal = oUDT.nSetKey(soNum)
retVal = oUDT.nSetValue("UDF_TYPE$",soType)
retVal = oUDT.nWrite()
end if
end if
if printOrder = "Y" then
For x = 1 to 2
' Terminate UI if you need to avoid screen prompts or
' do not terminate ui if you want to Print to preview
retVal = oSS.nTerminateUI()
' Select the Template record.
' The record must exist for the user/company, which means
' the user you are logging in as must have printed/previewed
' the form at least once in MAS.
retVal = soPRINT.nSelectReportSetting("AUTOMATED")
soPRINT.sQuickPrint = soNum
'soPRINT.nNumberOfCopies = 2
'retVal = soPRINT.nSelectReportSetting("AUTOMATED")
'retVal = soPRINT.nSetKeyValue("ReportSetting$", "AUTOMATED")
'retVal = soPRINT.nSetKeyValue("RowKey$", "1")
'retVal = soPRINT.nSetKey()
' Set Selection criteria
'retVal = soPRINT.nSetValue("SelectField$", "Order Number")
'retVal = soPRINT.nSetValue("SelectFieldValue$", "Order Number")
'retVal = soPRINT.nSetValue("Tag$", "TABLE=SO_SALESORDERHEADER; COLUMN=SALESORDERNO$")
'retVal = soPRINT.nSetValue("Operand$", "=")
' Available "Operand$" values
' All - "A"
' Begins with - "B"
' Ends with - "E"
' Contains - "C"
' Less than - "L"
' Greater than - "G"
' Range - "R"
' Equal to - "="
' Not Equal to - "N"
'retVal = soPRINT.nSetValue("Value1$", soNum)
' set Value2$ for a range oPICK.nSetValue("Value2$", LastOrderNo)
' Write report setting to memory
'retVal = soPRINT.nWrite()
' Call ProcessReport to execute the printout
' ProcessReport(Destination)
' Available Print destinations
' PRINT - print to printer
' DEFERRED - print to deferred
' PREVIEW - preview requires UI
retVal = soPRINT.nProcessReport("PRINT")
if retVal = 0 then
msgbox soPRINT.sLastErrorMsg
end if
Dim Starting, Ending, Diff
Starting = Now
Ending = DateAdd("s",1,Starting)
Do
Diff = DateDiff("s",Now,Ending)
if Diff <= 0 then Exit Do
WScript.Sleep 1000
Loop
retVal = oSO.nSetValue("PrintSalesOrders$","N")
retVal = oSO.nWrite()
Next
end if
retVal = oSO.nMoveNext()
Loop