Hello Friends,
How can i DOS print through VB.
Regards this i got a one reply in our group. It is like the below. It is
working fine. But what i want is,
>in this DOS printing how can i set Page Orientation
>and How can i set the Font. Is it possible? If so please send me this.
Thanx in advance.
Regards
Nag K.
*********************************************************
'Code Start-----------------
'Put this in a general module
Public Type DocInfo
pDocName As String
pOutPutFile As String
pDataType As String
End Type
Public Declare Function ClosePrinter Lib "winspool.drv" (ByVal _
hPrinter As Long) As Long
Public Declare Function EndDocPrinter Lib "winspool.drv" (ByVal _
hPrinter As Long) As Long
Public Declare Function EndPagePrinter Lib "winspool.drv" (ByVal _
hPrinter As Long) As Long
Public Declare Function OpenPrinter Lib "winspool.drv" Alias _
"OpenPrinterA" (ByVal pPrinterName As String, phPrinter As Long, _
ByVal pDefault As Long) As Long
Public Declare Function StartDocPrinter Lib "winspool.drv" Alias _
"StartDocPrinterA" (ByVal hPrinter As Long, ByVal Level As Long, _
pDocInfo As DocInfo) As Long
Public Declare Function StartPagePrinter Lib "winspool.drv" (ByVal _
hPrinter As Long) As Long
Public Declare Function WritePrinter Lib "winspool.drv" (ByVal _
hPrinter As Long, pBuf As Any, ByVal cdBuf As Long, _
pcWritten As Long) As Long
'This I call before printing
Public Sub SetLPrinter()
Dim MyDoc As DocInfo
Dim lReturn As Long
Dim lDoc As Long
lReturn = OpenPrinter(Printer.DeviceName, lhPrinter, 0)
MyDoc.pDocName = "Test1"
MyDoc.pOutPutFile = vbNullString
MyDoc.pDataType = vbNullString
lDoc = StartDocPrinter(lhPrinter, 1, MyDoc)
Call StartPagePrinter(lhPrinter)
End Sub
'This I call to clean up after printing
Public Sub KillLPrinter()
Dim lRet As Long
lRet = EndPagePrinter(lhPrinter)
lRet = EndDocPrinter(lhPrinter)
lRet = ClosePrinter(lhPrinter)
End Sub
'This I set somewhere globally
Public lhPrinter As Long
'A typical procedure to do some printing
Private sub PrintStuff()
Dim lReturn As Long
Dim lRet As Long
Dim PrintStr As String
Dim lpcWritten As Long
SetLPrinter
PrintStr = "This is line one" & vbCrLf _
& "This is line two" & vbCrLf
lReturn = WritePrinter(lhPrinter, ByVal PrintStr, Len(PrintStr),
lpcWritten)
KillLPrinter
End Sub
'Code End
--------------------
*********************************************************
Thanx in advance
Regards
Nag K.
_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*.
http://join.msn.com/?page=features/featuredemail