Results 1 to 6 of 6

Thread: printing-page break

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2002
    Posts
    15

    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

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    I saw this on here a few days ago, it should do nicely
    Attached Files Attached Files

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2002
    Posts
    15
    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
    Last edited by vbsamir; Aug 8th, 2002 at 08:18 AM.

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    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.

  5. #5

    Thread Starter
    New Member
    Join Date
    Aug 2002
    Posts
    15
    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

  6. #6
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    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)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width