Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing image files to specified printer

Status
Not open for further replies.

FoxFire5

Programmer
Sep 20, 2001
3
0
0
BE
Can anyone tell me how i can print an image file (for example a tif file) to a specified printer?
For this moment i use the shell command to print these files. This command will use the default printer of the server. My question is: is there a way to use an other printer (different than the default printer) to do this?

 
I have inherited a program from a Senior program that I think does what you want to do??? Here goes:

AppToRun = "C:\WINNT\System32\CMD.exe"
'//set Command Line Parameters
'//The "/C" Tells Windows to Run The Command then terminate
'//The Command Line (CMD.exe)
ParamForApp = " /C lpr -S (IP address of printer) -P raw -o i " & Sourcename
'//Make new Directory Called 'New_Folder'
'//Build Command string
CmdLine = AppToRun & ParamForApp
'//Shell App And Wait for It to Finish
ExecCmd CmdLine

~~~~~~~~~~~~~~~~
This code goes along with the module below:

Option Explicit
'//public Constants
Public Const NORMAL_PRIORITY_CLASS = &H20&
Public Const INFINITE = -1&
'//public Types
Public Type STARTUPINFO
cb As Long
lpReserved As String
lpDesktop As String
lpTitle As String
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Long
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type
Public Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessID As Long
dwThreadID As Long
End Type
'//API Declarations
Public Declare Function WaitForSingleObject Lib "kernel32" (ByVal _
hHandle As Long, ByVal dwMilliseconds As Long) As Long
Public Declare Function CreateProcessA Lib "kernel32" (ByVal _
lpApplicationName As Long, ByVal lpCommandLine As String, ByVal _
lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, _
ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, _
ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As Long, _
lpStartupInfo As STARTUPINFO, lpProcessInformation As _
PROCESS_INFORMATION) As Long

Public Declare Function CloseHandle Lib "kernel32" (ByVal _
hObject As Long) As Long

 
Actually, I just found this and you don't need the module for it:

ParamForApp = " /C lpr -S (printer IP Address) -P raw -o i " & Sourcename
AppToRun = "C:\WINNT\System32\CMD.exe"
x = Shell(AppToRun & ParamForApp, vbHide)

The sourcename is just the name of the file...in my program the use picks it from a directory search.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top