Jay,
We had the same problem here with HTML files. After hunting for software that would "send" unattended print and being told that there were none available, Brian (my co worker) would not accept this answer. Here is his solution:
Yes, this is a pain. We had a similar situation where one of our over night batch jobs needed to be printed and delivered to a user before they arrived at work. The print area was not too keen on having a file sent to them and opening it to print so we needed to come up with a way to print them in an unattended manner. Since this job runs with great regularity at around 3:00 am in the morning I came up with a VBScript that would submit the print around 4:00 am. This is not without faults do to set up but it works.
Hurdles:
1) Actually executing the Script
2) Data file is on Unix and Script requires a Windows platform
3) Selecting the correct printer - our print had to go to a mainframe printer and not a local printer attached to the machine
4) Box running the script has to have the desired printer defined
5) Script actually activates the Print Dialogue Box and requires the user to click the OK button
Solutions:
1) Our solution is to have a mainframe scheduler "ZEKE" execute the script. Others available are to have a machine's NT Scheduler execute the script or to set up a listener program on to a folder so that when a file appears in that folder to execute the script. (dont know how to set up the listener)
2) Expanded script to first FTP the file to a windows platform
3) Expanded script to select the desired printer
4) Went to that physical server and loaded that printer and set the default preferences so that when the script selected the printer, no preferences for that print job would need to be inputted.
5) This is the problematic one. The only way to get that blasted OK button to execute is to use "Send Key". Typically this is a HUGE "No No" in scripting due to security issues, but all it has to do is send an "Enter" command. Once the Print command is issued, time for rendering is needed so you have to have a sleep command to allow for rendering before the dialogue box appears. Also, if the box executing the script has a user on it, then when the Send Key command fires, the active app will receive an Enter command. When that dialogue box appears, you have to wait until the sleep command finishes and submits the enter key. This was solved by using a server that does not run apps or have a user sitting at it around 4 in the morning. Lastly, I had to set the default printer for that box back to its original setting so I needed some pre-information for that box.
D=Day(Date())
If M < 10 Then MM="0" & M Else MM=M End If
If D < 10 Then DD="0" & D Else DD=D End If
FILE_DATE = Y & MM & DD
Dim BATCH_File, FUNCT_File
BATCH_File="\\filepath\ftp.bat"
FUNCT_File="\\filepath\ftp"
Dim m_fso, n_ts, m_ts
'--CREATE THE FILE SYSTEM OBJECT
Set m_fso = CreateObject("Scripting.FileSystemObject")
'----CREATE THE BATCH FILE THAT RUNS THE FTP SCRIPT
Set m_ts = m_fso.CreateTextFile(BATCH_File, True)
'----CREATE THE FTP SCRIPT DOCUMENT
Set n_ts = m_fso.CreateTextFile(FUNCT_File, True)
'----WRITE THE BATCH FILE - THIS BATCH FILE IS ONLY TWO LINES LONG.
' IT CONTAINS THE CALL TO THE FTP SCRIPT AND THE LINE TO DELETE THE SCRIPT.
m_ts.WriteLine("ftp -s:\\filepath\ftp")
'----THE FTP SCRIPT FILE CONTAINS COMMANDS THAT SHOW THE USERS LOGON ID AND PASSWORD
' SO THE SCRIPT FILE NEEDS TO BE DELETED AFTER COMPLETION
m_ts.WriteLine("del \\filepath\ftp")
'----CLOSE THE BATCH FILE TEXT DOCUMENT
m_ts.close
'----END OF BATCH FILE WRITING
Dim Get_File
Get_File="/unixpathfordatafile/" & FILE_DATE & "_newbus.htm"
'----------------------------------------------------------
n_ts.WriteLine("open rimsdev")
n_ts.WriteLine("gb5i01")
n_ts.WriteLine("group1")
n_ts.WriteLine("cd /unixpathfordatafile")
n_ts.WriteLine("ascii")
n_ts.WriteLine("get " & Get_File & " \\filepath\" & FILE_DATE & "_newbus.htm")
n_ts.WriteLine("quit")
'----------------------------------------------------------
'----CLOSE THE FTP SCRIPT FILE TEXT DOCUMENT
n_ts.close
'----END OF FTP SCRIPT FILE WRITING
'----EXECUTE BATCH FILE
Dim WSHShell
Set WSHShell = CreateObject("Wscript.Shell")
WSHShell.Run("\\filepath\ftp.bat > \\filepath\bat_out.txt")
WScript.Sleep 10000
End Sub
'------------------------------------------------------------------------------------------------------------
' PRINT SUBROUTINE
'------------------------------------------------------------------------------------------------------------
Sub prt()
'----GENERATE EXECUTION DATE TO MATCH TO IDCARD FILE
Dim Y,M,D,DD,MM
Dim Exec_Date
Dim File_Date
Y=Year(Date())
M=Month(Date())
D=Day(Date())
If M < 10 Then MM="0" & M Else MM=M End If
If D < 10 Then DD="0" & D Else DD=D End If
Exec_Date = Y & MM & DD
'-------------------------------------------------------------------
' READ NAME OF FILES IN THE IDCARD FOLDER TO LOCATE
' THE FILE WITH TODAYS EXECUTION DATE AND GIVE THE
' "GO" TO THE GO-NO-GO VARIABLE AND PROCESS PRINT
'-------------------------------------------------------------------
Dim TargetFolder
Dim objShell
Dim objFolder
Dim colItems
Dim i
TargetFolder = "\\filepath"
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(TargetFolder)
Set colItems = objFolder.Items
For i = 0 to colItems.Count - 1
File_Date = Left(colItems.Item(i).name,8)
If File_Date = Exec_Date Then
colItems.Item(i).InvokeVerbEx("Print")
'----GIVE TIME FOR HTML RENDERING BEFORE SENDING COMMAND
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
WScript.Sleep 105000
WshShell.SendKeys "{ENTER}"
Else
End If
Next
End Sub
'------------------------------------------------------------------------------------------------------------
' SET PRINTER TO 11TH FLOOR AND RUN SUBROUTINES
'------------------------------------------------------------------------------------------------------------
'-------------------------------------------------------------------
' ENUMERATE PRINTERS AVAILABLE TO COMPUTER
'-------------------------------------------------------------------
'Option Explicit
Dim oPrinter, oNetwork, iCount
Set oNetwork = WScript.CreateObject("WScript.Network")
Set oPrinter = oNetwork.EnumPrinterConnections
'-------------------------------------------------------------------
' SET DEFAULT PRINTER
'-------------------------------------------------------------------
Dim objPrinter
Set objPrinter = CreateObject("WScript.Network")
objPrinter.SetDefaultPrinter "\\SRVPRINT\Xerox..."
'-------------------------------------------------------------------
'
'-------------------------------------------------------------------
ftp()
prt()
'-------------------------------------------------------------------
' RESET DEFAULT PRINTER
'-------------------------------------------------------------------
objPrinter.SetDefaultPrinter "\\SRVPRINT\grpqual"
Hope this helps you in some way.
Glenda and Brian
Glenda
In FOCUS Since 1990
Production 8.2 Windows