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 Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't get a page break while printing with Win API

Status
Not open for further replies.

btt423

Programmer
Jan 28, 2002
31
US
I'm researching talking directly with a printer using the API. I can not seem to get a print job to print multiple pages. I thought that the EndPagePrinter function call would end one page, and the the StartPagePrinter would start another one, but everything is printing on one page.

Here is a code sample:

Code:
Dim lhPrinter As Long
Dim lReturn As Long
Dim lpcWritten As Long
Dim lDoc As Long
Dim sWrittenData As String
Dim MyDocInfo As DOCINFO
Dim i As Integer


lReturn = OpenPrinter(Printer.DeviceName, lhPrinter, 0)
'lReturn = OpenPrinter("\\oocfiles\hp5p264i", lhPrinter, 0)
'lReturn = OpenPrinter("\\oocfiles\hp4100_226", lhPrinter, 0)

If lReturn = 0 Then
    MsgBox "The Printer Name you typed wasn't recognized."
    Exit Sub
End If



MyDocInfo.pDocName = "AAAAAA"
MyDocInfo.pOutputFile = vbNullString
MyDocInfo.pDatatype = vbNullString
lDoc = StartDocPrinter(lhPrinter, 1, MyDocInfo)
Call StartPagePrinter(lhPrinter)
    
For i = 1 To 2
  sWrittenData = "Page " & i
  lReturn = WritePrinter(lhPrinter, ByVal sWrittenData, _
    Len(sWrittenData), lpcWritten)
  lReturn = EndPagePrinter(lhPrinter)
Next i

lReturn = EndDocPrinter(lhPrinter)
lReturn = ClosePrinter(lhPrinter)

Any suggestions would be appreciated.

Thanks, Brinson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top