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

Printer.Print Working/Not Working

Status
Not open for further replies.

stnkyminky

Programmer
Oct 15, 2001
476
US
I am using printer.print inorder to print Avery labels.
Through a sequencing loop I receive the following printout which is correct.
D03303 ( 1 )
Job# C228A5 SO# 31028
Part# 714021-01 STN:24
Descr

When I attempt to print the 2nd label I receive this:
D03303 ( 2 ) which should be

D03303 ( 2 )
Job# C228A5 SO# 31028
Part# 714021-01 STN:24
Descr

This occurs for the rest of the row. However, each time a new row is started the JOB#, SO#, etc is printed only on the first label and not the second, third.

Thanks in advance.



Scott
Programmer Analyst
 
without seeing the code, one can't even guess, unless you count "Programmer Error"! Tim

Remember the KISS principle:
Keep It Simple, Stupid! :cool:
 
For x = 1 To foo ' number of rows total labels div by 3 (rounded)


For i = 1 To 3 'endCol
'If the label count is more than the qty then print blanks
If count > qty Then '10 = qty
num = ""
End If

If (x Mod 10) = 0 Then
objLabel.LabelPrint x, i, "D03303 ( " & num & " )", "Job# C228A5 SO# 31028", "Part# 714021-01 STN:24", "Descr"
Else
objLabel.LabelPrint CInt(x Mod 10), i, "D03303 ( " & num & " )", "Job# C228A5 SO# 31028", "Part# 714021-01 STN:24", "Descr"
End If

If count = total Then
objLabel.PageFinished
Exit Sub
End If
count = count + 1
num = count
Next 'end rows

If (x Mod 10) = 0 Then
objLabel.PageFinished
' Printer.CurrentY = 0
' Printer.CurrentX = 0
ElseIf count = total Then
objLabel.PageFinished
End If

Next ' end columns

========ObjLabel Class====================
Option Explicit

Private m_Inprogress As Boolean 'Has a label been setup and not yet printed?
Private m_iBigFont As Integer 'First Row Font Size
Private m_iLittleFont As Integer 'Second Row Font Size

Private Const m_MaxCol = 3 'Maximum # of columns of labels
Private Const m_MaxRow = 30 'Maximum # of rows of labels
Private Const m_Top = 1 'Top margin (dist from top of page to 1st label)
Private Const m_LeftOne = 0.19 'Left margin (dist from left of page to label)
Private Const m_LeftTwo = 2.9 'Left margin of 2nd label
Private Const m_LabelHeight = 1.2 'Height of label in inches
Private Const m_LabelWidth = 2.75 'Width of one label
Private Const TwipsPerInch = 1440 'Number of twips in one inch
Dim LabelX As Double
Dim LabelY As Double

'Const HP_Top_Border_Adjustment = (6 / 16) * TwipsPerInch
'Const HP_Top_Border_Adjustment = -1 * (0.25 * 1440#)

Dim HP_Top_Border_Adjustment As Long 'top of page offset fudge factor

Property Let BigFont(fsize As Integer) 'Sets fontsize of first label row
m_iBigFont = fsize
End Property
Property Let LittleFont(fsize As Integer) 'Sets fontsize of second label row
m_iLittleFont = fsize
End Property
Property Get TopBorderAdjustment() As Long 'Returns top border fudge factor (twips)
TopBorderAdjustment = HP_Top_Border_Adjustment
End Property
Property Let TopBorderAdjustment(newValue As Long) 'Sets top border fudge factor (twips)
HP_Top_Border_Adjustment = newValue
End Property
Property Get JobStarted() As Boolean 'Returns in-process flag
JobStarted = m_Inprogress
End Property
Sub PageFinished() 'Finish page and clear in-process flag
Printer.EndDoc
'Set Printer = Nothing
'printer.EndDoc
' LabelX = 0
' LabelY = 0
' Printer.CurrentX = 0
' Printer.CurrentY = 0
m_Inprogress = False
End Sub
Sub LabelPrint(TargRow As Integer, TargCol As Integer, MessageData As String, MessageData2 As String, MessageData3 As String, MessageData4 As String)
'This subroutine puts the data at the right place to print.
' The PageFinished routine above does the actual enddoc.

'Make sure that we are within the labels rows/columns limits.
If TargRow > m_MaxRow Or TargCol > m_MaxCol Then Return

'set the inprogress flag as active
m_Inprogress = True

'setup variables for label positions
' Dim LabelX As Double
' Dim LabelY As Double
' If (TargRow Mod 10) = 1 And TargRow <> 1 Then
' LabelY = 0
' LabelX = 0
' Printer.CurrentX = 0
' Printer.CurrentY = 0
' End If
'set first label row font size
Printer.FontSize = m_iBigFont

'calculate label position based on the label row
LabelY = (TargRow - 1) * (TwipsPerInch * m_LabelHeight)


'LabelY = LabelY + HP_Top_Border_Adjustment
'adjust for first row of text
' HA! No need for FIRST row adjustment! The printer object is keying
' off of the TOP of the character!!!!! In other words, when we say print
' at 0 units from the top, Windows uses the TOP of the character to set
' the line so that it prints correctly.

If TargCol = 1 Then
LabelX = 0
Else
'LabelX = TwipsPerInch * m_LabelWidth
LabelX = TwipsPerInch * (m_LeftOne + (TargCol - 1) * 2.75)
End If

Printer.CurrentX = LabelX
Printer.CurrentY = LabelY

'hard code in the y position for the last label
If (TargRow Mod 10) = 0 Then
Printer.CurrentY = 13279
LabelY = 13279
End If
'Output first line of label
Printer.Print MessageData
'NOTE: Once we print, the CurrentY changes to the next line . . .

'Setup for second row position
'Debug.Print Printer.CurrentY
Printer.CurrentY = Printer.CurrentY + Printer.TextHeight(MessageData)
'Debug.Print &quot;1: &quot; & TargRow & &quot; &quot; & Printer.CurrentY
'LabelX = LabelX + 10
Printer.CurrentX = LabelX
Printer.FontSize = m_iLittleFont
Printer.Print MessageData2

Printer.CurrentY = Printer.CurrentY + Printer.TextHeight(MessageData2)
'Debug.Print &quot;2: &quot; & TargRow & &quot; &quot; & Printer.CurrentY
'LabelX = LabelX + 10
Printer.CurrentX = LabelX
Printer.FontSize = m_iLittleFont
Printer.Print MessageData3

Printer.CurrentY = Printer.CurrentY + Printer.TextHeight(MessageData3)
'Debug.Print &quot;3: &quot; & TargRow & &quot; &quot; & Printer.CurrentY
'LabelX = LabelX + 10
Printer.CurrentX = LabelX
Printer.FontSize = m_iLittleFont
Printer.Print MessageData4
' Printer.EndDoc

End Sub

Private Sub Class_Initialize()
m_Inprogress = False 'No labels initialized yet
m_iBigFont = 12 'Default to 36 point first row font
m_iLittleFont = 10 'Default to 10 point second row font



HP_Top_Border_Adjustment = (0.3 * 1440) 'Use 288 twips for top border
End Sub

Private Sub Class_Terminate()
If m_Inprogress = True Then
Printer.EndDoc 'If labels have been initialized, print them
m_Inprogress = False ' clear in process flag
End If
End Sub
Scott
Programmer Analyst
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top