Printing

I need to specify a UNC for a printer so that no matter what, my vb application always prints to it.It is on an NT 4.0 platform. I have no idea about API and need help ASAP.
This is the code i have:
For Each obj In Printers
If obj.DeviceName = "\\SSSYS1\\SS01F203" Then
Set Printer = obj
Else
MsgBox "Printer Not Defined"
End
End If

Next obj

Dim strCommandLine1 As String
Dim strPrinterName1 As String
Dim strDriverName1 As String
Dim strPortName1 As String
Dim strFileNameToPrint1 As String

strFileNameToPrint1 = "C:\Temp\inpatregtemp.pdf"
strPrinterName1 = Printer.DeviceName
strDriverName1 = Printer.DriverName
strPortName1 = Printer.Port
strCommandLine1 = "c:\Program files\adobe\acrobat 4.0\reader\AcroRd32.exe /t """ + _
strFileNameToPrint1 + """ """ + _
strPrinterName1 + """ """ + _
strDriverName1 + """ """ + _
strPortName1 + """"
Shell (strCommandLine1)

End Sub

Thanks in advance
Patrick
[1073 byte] By [JPBURBE] at [2007-11-15 16:16:46]
# 1 Re: Printing
Patrick,

I had a similar problem and the best way I found was to use the FileSystemObject like so...

Dim FSO as new FileSystemObject
FSO.CopyFile strFileNameToPrint, "\\SSSYS\SS01F203"
set FSO = nothing

Where "\\SSSYS1\SS01F203" I imagine is the name of your print server and printer name.

This is a very simple way to do this, and it works.

Make sure to set a reference to Microsoft Scripting Runtime.

Hope that helps...

Sean
Dark Sean at 2007-11-10 0:59:12 >
# 2 Re: Printing
Option Compare Database
Option Explicit

Const PRINTER_ENUM_CONNECTIONS = &H4
Const PRINTER_ENUM_LOCAL = &H2

Type PRINTER_INFO_1
flags As Long
pDescription As String
PName As String
PComment As String
End Type

Type PRINTER_INFO_4
pPrinterName As String
pServerName As String
Attributes As Long
End Type

Declare Function EnumPrinters Lib "winspool.drv" Alias _
"EnumPrintersA" (ByVal flags As Long, ByVal name As String, _
ByVal Level As Long, pPrinterEnum As Long, ByVal cdBuf As Long, _
pcbNeeded As Long, pcReturned As Long) As Long
Declare Function PtrToStr Lib "Kernel32" Alias "lstrcpyA" _
(ByVal RetVal As String, ByVal Ptr As Long) As Long
Declare Function StrLen Lib "Kernel32" Alias "lstrlenA" _
(ByVal Ptr As Long) As Long
smalldot at 2007-11-10 1:00:09 >