This code works beautifully in the element programming:
// Prints the Over 30 Days by Customer report
var vPrintTheReport as String
var vTemp as String
var vFilename as String
var vNewFilename as String
var vPos as Int
var vShell as Int
IF NOT @Mode() = 0
THEN
{
vPrintTheReport = @PrintAReport(". Over 30 Days, sorted by Customer", REPORT_MODE_HTML_PREVIEW, PRINT_ORIENTATION_PORTRAIT, 0, -1, -1, -1, -1, -1, -1)
}
ELSE @MSGBOX("This Report can only be run in Update mode",
"Please switch to Search/Update and try again",
"")
// File rename procedure
// Get just the filename off the full path
vTemp = @ReplLas(vPrintTheReport, "\", "^")
vPos = @Instr(vTemp, "^")
vFilename = @Mid(vTemp, vPos + 1, @Len(vTemp) - vPos)
// Make the new filename
vNewFilename = @UserID + "_" + vFilename
// Issue the rename command
vShell = @Shell("REN " + @Chr(34) + vPrintTheReport + @Chr(34) + " " + @Chr(34) + vNewFilename + @Chr(34))
I've messed around with numerous permutations, but what I started with was putting this in Global code:
SUBROUTINE ChangeReportFilename()
var vPrintTheReport as String
var vTemp as String
var vFilename as String
var vNewFilename as String
var vPos as Int
var vShell as Int
// Get just the filename off the full path
vTemp = @ReplLas(vPrintTheReport, "\", "^")
vPos = @Instr(vTemp, "^")
vFilename = @Mid(vTemp, vPos + 1, @Len(vTemp) - vPos)
// Make the new filename
vNewFilename = @UserID + "_" + vFilename
// Issue the rename command
vShell = @Shell("REN " + @Chr(34) + vPrintTheReport + @Chr(34) + " " + @Chr(34) + vNewFilename + @Chr(34))
END SUBROUTINE
And changing the element code to
// Prints the Over 30 Days by Customer report
var vPrintTheReport as String
var vTemp as String
var vFilename as String
var vNewFilename as String
var vPos as Int
var vShell as Int
IF NOT @Mode() = 0
THEN
{
vPrintTheReport = @PrintAReport(". Over 30 Days, sorted by Customer", REPORT_MODE_HTML_PREVIEW, PRINT_ORIENTATION_PORTRAIT, 0, -1, -1, -1, -1, -1, -1)
}
ELSE @MSGBOX("This Report can only be run in Update mode",
"Please switch to Search/Update and try again",
"")
ChangeReportFilename()