title: Send Raw Data to ZPL Printer using Visual Basic (MS Access 2000)
body: <p>This is all that I can find, none of them work.</p>
  
  <p>Option Compare Database
  Option Explicit</p>
  
  <pre><code>  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 TEST()
        Dim lhPrinter As Long
        Dim lReturn As Long
        Dim lpcWritten As Long
        Dim lDoc As Long
        Dim sWrittenData As String
        Dim MyDocInfo As DOCINFO
        lReturn = OpenPrinter("ZDesigner LP 2844", 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)
         sWrittenData = "N" &amp; vbFormFeed
        sWrittenData = sWrittenData &amp; "q609" &amp; vbFormFeed
        sWrittenData = sWrittenData &amp; "Q203,26" &amp; vbFormFeed
        sWrittenData = sWrittenData &amp; "B26,26,0,UA0,2,2,152,B," &amp; Chr(34) &amp; "603679025109" &amp; Chr(34) &amp; vbFormFeed
        sWrittenData = sWrittenData &amp; "A253,26,0,3,1,1,N," &amp; Chr(34) &amp; "SKU 6205518 MFG 6354" &amp; Chr(34) &amp; vbFormFeed
        sWrittenData = sWrittenData &amp; "A253,56,0,3,1,1,N," &amp; Chr(34) &amp; "2XIST TROPICAL BEACH" &amp; Chr(34) &amp; vbFormFeed
        sWrittenData = sWrittenData &amp; "A253,86,0,3,1,1,N," &amp; Chr(34) &amp; "STRIPE SQUARE CUT TRUNK" &amp; Chr(34) &amp; vbFormFeed
        sWrittenData = sWrittenData &amp; "A253,116,0,3,1,1,N," &amp; Chr(34) &amp; "BRICK" &amp; Chr(34) &amp; vbFormFeed
        sWrittenData = sWrittenData &amp; "A253,146,0,3,1,1,N," &amp; Chr(34) &amp; "X-LARGE" &amp; Chr(34) &amp; vbFormFeed
        sWrittenData = sWrittenData &amp; "P1,1" &amp; vbFormFeed
        lReturn = WritePrinter(lhPrinter, ByVal sWrittenData, _
           Len(sWrittenData), lpcWritten)
        lReturn = EndPagePrinter(lhPrinter)
        lReturn = EndDocPrinter(lhPrinter)
        lReturn = ClosePrinter(lhPrinter)
    End Sub
  </code></pre>
  
  <p>Method 2</p>
  
  <pre><code>Option Compare Database
  
  Private Sub crtLabel()
  
  
  Dim prtDevice As String
  Dim strQuote As String
  
  strQuote = Chr(34)
  prtDevice = "ZDesigner LP 2844" ' whatever device Access currently has as the default. I have the user select a printer prior to printing, which sets the Access defaut printer
  
  ' open printer port
  Open prtDevice For Output As #1
  ' initialize printer
  Print #1, "OD" &amp; vbCrLf
  Print #1, "N" &amp; vbCrLf
  Print #1, "O" &amp; vbCrLf
  Print #1, "Q545,B12+23" &amp; vbCrLf
  Print #1, "q262" &amp; vbCrLf
  Print #1, "UN" &amp; vbCrLf
  Print #1, "rN" &amp; vbCrLf
  Print #1, "N" &amp; vbCrLf
  Print #1, "A4,94,3,3,1,1,N," &amp; strQuote &amp; "1803" &amp; strQuote &amp; vbCrLf
  Print #1, "A36,74,3,3,1,1,N," &amp; strQuote &amp; "B" &amp; strQuote &amp; vbCrLf
  Print #1, "A64,94,3,3,1,1,N," &amp; strQuote &amp; "079" &amp; strQuote &amp; vbCrLf
  Print #1, "A112,8,0,2,1,1,N," &amp; strQuote &amp; strQuote &amp; vbCrLf ' you can replace any string like "1803" with a string variable like SID or AID that gets passed to the sub
  Print #1, "A112,32,0,3,1,1,N," &amp; strQuote &amp; strQuote &amp; vbCrLf  ' same here
  Print #1, "A112,64,0,1,1,1,N," &amp; strQuote &amp; "04/13/2009" &amp; strQuote &amp; vbCrLf
  Print #1, "A130,100,0,1,1,1,N," &amp; strQuote &amp; "SWAB, NASO" &amp; strQuote &amp; vbCrLf
  Print #1, "A4,100,0,1,1,1,N," &amp; strQuote &amp; "C146536" &amp; strQuote &amp; vbCrLf
  Print #1, "B53,130,0,1,1,0,47,N," &amp; strQuote &amp; "2009-06868" &amp; strQuote &amp; vbCrLf
  Print #1, "A112,188,0,1,1,1,N," &amp; strQuote &amp; "" &amp; strQuote &amp; vbCrLf
  Print #1, "P1,1" &amp; vbCrLf
  Print #1, "O" &amp; vbCrLf
  ' close printer port
  Close #1
  
  
  End Sub
  </code></pre>
  
  <p>Nothing happens after running the function. It's like the printer is not touched at all by the code.</p>
  
  <p><strong>UPDATE</strong>
  Method 1 is the closest thing I can get to printing the file. After executing the command, there is a printer icon at the status bar show that the printer has been called and receiving data from my code, but still, no printing at all. Help...</p>