vbCrLf or vbNewLine not working in dot matrix printer (1 Viewer)

Loek

Registered User.
Local time
Today, 09:25
Joined
Feb 6, 2011
Messages
14
Hi, everybody
I have a problem with an epson lx300 + dot matrix printer. The vba vbCrLf code doesn't work when I print text line by line. Have you ever experienced the same thing?

I use this code :

strLine as string
Dim lReturn As Long, lpcWritten As Long, sWrittenData As String

strLine ="one" & vbCrLf & _
"two" & vbCrLf & _
"some word"

sWrittenData = strLine & vbCrLf & vbCrLf
lReturn = WritePrinter(lhPrinter, ByVal sWrittenData, _
Len(sWrittenData), lpcWritten)
lReturn = EndPagePrinter(lhPrinter)
lReturn = EndDocPrinter(lhPrinter)


the result should be like this :
one
two
some word

But I get like this :
one-*two-*some word-*-*

I tried with vbNewLine but the results are still the same. I replaced it with Chr(13) & Chr(10), the results are still the same
 

jdraw

Super Moderator
Staff member
Local time
Yesterday, 22:25
Joined
Jan 23, 2006
Messages
15,423
Please post all of the related vba code. Use code tags.
What are
-WritePrinter
-EndPagePrinter
-EndDocPrinter
 

Loek

Registered User.
Local time
Today, 09:25
Joined
Feb 6, 2011
Messages
14
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

Dim lhPrinter As Long
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 21:25
Joined
Feb 28, 2001
Messages
27,511
First, how is this printer connected to your computer? Networked or through a COM port?

Second, as jdraw suggests, it would be good to know what those routines are that you called.

If they are local and not too long, it would be nice to see their content. If they come from a library, which library?
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 21:25
Joined
Feb 28, 2001
Messages
27,511
OK, your post crossed with mine. Don't do what you are doing. Create a file using the Open statement in VBA. When you close it, send the file to the printer or use a Shell command to print the file.



 

Loek

Registered User.
Local time
Today, 09:25
Joined
Feb 6, 2011
Messages
14
The printer is connected by USB and is local without an internet connection.
all code is in a form with one commond button to print text line by line

strLine as string
Dim lReturn As Long, lpcWritten As Long, sWrittenData As String

strLine ="one" & vbCrLf & _
"two" & vbCrLf & _
"some word"

sWrittenData = strLine & vbCrLf & vbCrLf
lReturn = WritePrinter(lhPrinter, ByVal sWrittenData, _
Len(sWrittenData), lpcWritten)
lReturn = EndPagePrinter(lhPrinter)
lReturn = EndDocPrinter(lhPrinter)
 

Users who are viewing this thread

Top Bottom