Z
zulander
Hi, i am having problem printing a text to the printer. it print's but
only one line.
this is my function, thnak you
Public Function PrintTo(deviceindex As Integer, txt As String) As Long
Dim DocIn As DOCINFO
Dim xhdc As Long
Dim xOut As String
Dim splitLine() As String
xhdc = CreateDC(Access.Printers(deviceindex).DriverName,
Access.Printers(deviceindex).DeviceName, 0, 0)
Find_XY = Set_XY(xhdc)
DocIn.cbSize = Len(DocIn)
DocIn.lpszDocName = "Generator Inventory"
DocIn.lpszDatatype = vbNullString
DocIn.lpszOutput = vbNullString
xOut = Rectangle(xhdc, 10, 10, 1000, 150)
xOut = StartDoc(xhdc, DocIn)
xOut = StartPage(xhdc)
splitLine = Split(txt, vbCrLf)
For i = LBound(splitLine) To UBound(splitLine)
xOut = TextOut(xhdc, 0, 0, splitLine(i), Len(splitLine(i)))
Next
xOut = EndPage(xhdc)
xOut = EndDoc(xhdc)
GetHdc = DeleteDC(xhdc)
End Function
only one line.
this is my function, thnak you
Public Function PrintTo(deviceindex As Integer, txt As String) As Long
Dim DocIn As DOCINFO
Dim xhdc As Long
Dim xOut As String
Dim splitLine() As String
xhdc = CreateDC(Access.Printers(deviceindex).DriverName,
Access.Printers(deviceindex).DeviceName, 0, 0)
Find_XY = Set_XY(xhdc)
DocIn.cbSize = Len(DocIn)
DocIn.lpszDocName = "Generator Inventory"
DocIn.lpszDatatype = vbNullString
DocIn.lpszOutput = vbNullString
xOut = Rectangle(xhdc, 10, 10, 1000, 150)
xOut = StartDoc(xhdc, DocIn)
xOut = StartPage(xhdc)
splitLine = Split(txt, vbCrLf)
For i = LBound(splitLine) To UBound(splitLine)
xOut = TextOut(xhdc, 0, 0, splitLine(i), Len(splitLine(i)))
Next
xOut = EndPage(xhdc)
xOut = EndDoc(xhdc)
GetHdc = DeleteDC(xhdc)
End Function