-
printing-page break
msg ="hello friends"
Printer.Print msg
Printer.Print ""
Printer.EndDoc
Printer.KillDoc
this code prints on lq1050+ dmp
but skip the complete page
can any body help to stop the printer -- remove the page break
i want it should print "hello friends" and stop there itself
regards
-
1 Attachment(s)
I saw this on here a few days ago, it should do nicely ;)
-
thanq very much.. it is working fine
the code is :
----------------------------------------------------
Option Explicit
Private Type DOCINFO
pDocName As String
pOutputFile As String
pDatatype As String
End Type
Private Declare Function ClosePrinter Lib "winspool.drv" (ByVal _
hPrinter As Long) As Long
Private Declare Function EndDocPrinter Lib "winspool.drv" (ByVal _
hPrinter As Long) As Long
Private Declare Function EndPagePrinter Lib "winspool.drv" (ByVal _
hPrinter As Long) As Long
Private Declare Function OpenPrinter Lib "winspool.drv" Alias _
"OpenPrinterA" (ByVal pPrinterName As String, phPrinter As Long, _
ByVal pDefault As Long) As Long
Private Declare Function StartDocPrinter Lib "winspool.drv" Alias _
"StartDocPrinterA" (ByVal hPrinter As Long, ByVal Level As Long, _
pDocInfo As DOCINFO) As Long
Private Declare Function StartPagePrinter Lib "winspool.drv" (ByVal _
hPrinter As Long) As Long
Private Declare Function WritePrinter Lib "winspool.drv" (ByVal _
hPrinter As Long, pBuf As Any, ByVal cdBuf As Long, _
pcWritten As Long) As Long
Private Sub Form_Load()
'Setting printer properties for report
Printer.ScaleMode = vbInches
Printer.FontSize = 12
Printer.FontName = "Arial"
'The code below can be placed in any subroutine to be called, you do not have
'to put it in form load.
Dim sWrittenData As String
sWrittenData = "Hi there!"
Call PrintNow(sWrittenData)
End Sub
Private Sub PrintNow(sWrittenData As String)
Dim lhPrinter As Long
Dim lReturn As Long
Dim lpcWritten As Long
Dim lDoc As Long
Dim MyDocInfo As DOCINFO
lReturn = OpenPrinter(Printer.DeviceName, lhPrinter, 0)
If lReturn = 0 Then
MsgBox "The Printer Name you typed wasn't recognized."
Exit Sub
End If
MyDocInfo.pDocName = "Document 1"
MyDocInfo.pOutputFile = vbNullString
MyDocInfo.pDatatype = vbNullString
lDoc = StartDocPrinter(lhPrinter, 1, MyDocInfo)
Call StartPagePrinter(lhPrinter)
sWrittenData = sWrittenData & vbCrLf
lReturn = WritePrinter(lhPrinter, ByVal sWrittenData, _
Len(sWrittenData), lpcWritten)
lReturn = EndPagePrinter(lhPrinter)
lReturn = EndDocPrinter(lhPrinter)
lReturn = ClosePrinter(lhPrinter)
End Sub
-------------------------
a litle trouble
i want to print multiple test on different position of the paper
i tried setting printer.currentx & currenty different values before calling printnow programme
but it prints only from 0th col. of the next line
pl. help me out
regards
-
I've looked at the code, but it seems you can only set the text...
you'll have to send text codes (ie: spaces & chr 13 and/or 10) to set the position.
-
but where to put the spaces ie chr 13 etc. in the programme
please change the programme and send the code
i will thankfull
regards
-
Instead of:
sWrittenData = "Hi there!"
Call PrintNow(sWrittenData)
(in form_load)
Try:
sWrittenData = "Hi there!"
Call PrintNow(sWrittenData)
sWrittenData = chr(13) & " Another line!"
Call PrintNow(sWrittenData)