Solved

Printer Object / Dot Matrix Priners

Posted on 2000-03-07
2
159 Views
Last Modified: 2010-05-02
I am having trouble printing labels (8 down x 4 across) with an OKI dot matrix/A4 printer. I am trying to use the printer object and set the 'PaperSize' property to 256(User defined) and then setting what I think are the right measurements of the page of labels in the 'Height' and 'Width' properties of the printer object.
The 'ScaleMode' property is set to twips. I have no problem getting the height to be high enough but not the width. The widest it will go is the same width as the A4 page.

Can anyone shed light on the situation for me as to what I'm doing wrong or not doing at all?

Thanks in advance.
0
Comment
Question by:mickdoherty
2 Comments
 
LVL 2

Expert Comment

by:damienm
ID: 2592374
If it is an A4 Printer why do you want to print any wider than A4?
0
 
LVL 32

Accepted Solution

by:
bhess1 earned 150 total points
ID: 2593404
The maximum width in this case is controlled by your Windows printer driver.  If your driver is coded so that the maximum width is "A4" paper width, then you won't be able to print beyond that using the Printer object.

Assuming that the printer will print wider than "A4", you have two possible answers.  One, find a printer driver that allows you to use the full width capability of the printer.

If you can't find such a driver, you can always send what you need to print directly to the printer.  You will lose a lot of versatility, but if you have to, you have to.  

To do this, you will need to open your LPT: port for binary access, e.g.

 PrintFile = FreeFile
 Open "LPT2" For Binary As #(PrintFile)

Spacing, line feeds, bold, italic, underline, etc. will need to be controlled explicitly.  For example, to switch your printer into and out of 'compressed' print mode, the commands might be:

 CompOn = Chr(15)
 CompOff = Chr(18)

In place of Printer.Print, you would use something like this:

 Global Col as Integer
 Global Row as Integer

 Sub PrintDirect(ByVal S$, Optional ByVal DoCR)

    Put #(PrintFile), , S
    Col=Col + Len(S)
    If DoCR = True Then
        Put #(PrintFile), , vbCrLf
        Col = 1
        Row = Row + 1
    End If

 End Sub

 Sub PositionPrinter(ByVal GotoCol, ByVal GotoRow)

    If GotoCol>Col Then
        Put #(PrintFile), , _
           Space(GotoCol-Col)
        Col = GotoCol
    End If
    Do While Row<GotoRow
        Put #(PrintFile), , _
          Chr(10) ' Line Feed
        Row = Row + 1
    Loop

End Sub

Sub BoldPrint(On)
    If On Then
        Put #(PrintFile), , BoldOn
    Else
        Put #(PrintFile), , BoldOff
    End If
End Sub
Now, printing would be something like this:

  Col=1
  Row=1

  PrintDirect "My Name"  ' Col now = 8

  PositionPrinter 30,3   ' Col=30, Row=3
  BoldPrint True
  PrintDirect "Your Name", True
        ' Col = 1, Row = 4
  BoldPrint False
..
..
..

Hope this helps
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now