Script to Export SO

SUGGESTED

I'm working on a button script ("Execute on Server" selected, MAS 200) that will export a PDF of a Sales Order to a specific location without prompting the user. I'm running into some strange issues and was hoping someone has seen some of these things before. First, here is my script so far:

'Script to "export" SO to file

'Init VARs
sSONum = ""

dim path
path = "\\fileserver\Sage_Server\email_files\"

nOutputFormat = 0
sOutputPath = ""

retVal = oBusObj.GetValue("SalesOrderNo$",sSONum)

Set oSOPrint = oSession.AsObject(oSession.GetObject("SO_SalesOrderPrinting_rpt"))

retVal = oSOPrint.SetOptions(options)
oSOPrint.ReportType = 6

retval = oSOPrint.InitReportEngine()

retVal = oSOPrint.SelectReportSetting("SOFORM")

nOutputFormat = 5
sOutputPath = path & "Order_" & sSONum & ".pdf"
retVal = oSession.AsObject(oSession.UI).MessageBox("",sOutputPath)

retval = oSOPrint.SetExportOptions(nOutputFormat, sOutputPath)

retVal = oSOPrint.ProcessReport("EXPORT")

retVal = oSession.AsObject(oSession.UI).MessageBox("",osession.lasterrormsg)

The strange things that are happening is the sOutputPath is displaying with no "\" and where the "\" should be, there are new lines. So instead of "\\fileserver\Sage_Server\email_files\Order_123456.pdf", I'm getting:

fileserver

Sage_Server

email_files

Order_123456.pdf

No matter how I add quotes or additional backslashes, I can't seem to get it to display properly. I'm assuming that's part of the problem of it not exporting the PDF.

The other strange thing is that the oSession.LastErrorMsg is displaying as: "Module P/R is not on file." We DON'T have the payroll module, but that shouldn't even be trying to use that module. Hopefully it's something simple that's wrong in my code (I did a lot of reverse engineering of it from various semi-related posts on here). Thanks in advance!