Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Laurence Lombard
 
Posts: n/a
Default Printing labels on a dot matrix printer - what does this code do

In my search for a method to print labels on a dot matrix printer from Excel
I found the post http://www.theofficeexperts.com/for...hread.php?t=831 which
gave a fine solution, but there is a bit of code which I do not understand.
(My VBA is self taught via trial and error).

PauseTime = 2 ' Set duration.
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
DoEvents ' Yield to other processes.
Loop

..
The code writes to PRINTLABEL.TXT and then executes a PRINTLABEL.BAT (which
contains the line "copy PRINTLABEL.TXT lpt1") for the number of times one
wants the label printed. I suspect the code above slows down the execution
so that the BAT file does not run faster than the printer can print.

Thanks
Laurence

An abbreviated version of the code follows for details sake. It works well
and I thought other that use this forum might also find it useful.

----------------------------------------------------------------------------
--------------
Private Sub PRINTLABEL_Click()
On Error GoTo Err_PRINTLABEL_Click

Dim Message, Title
Dim NUMCOPIES As Integer
Dim PauseTime, Start, Finish, TotalTime
Dim PRINTLINE1 As Variant
Dim PRINTLINE2 As Variant
Dim PRINTLINE3 As Variant
Dim PRINTLINE4 As Variant
Dim PRINTLINE5 As Variant
Dim PRINTLINE6 As Variant
Dim RetVal

Open "c:\PRINTLABEL.TXT" For Output Shared As #1


PRINTLINE1 = [Mr/Mrs] & " " & [ContactFirstName] & " " & [ContactLastName]
PRINTLINE2 = [CompanyName]
PRINTLINE3 = [Address1]
PRINTLINE4 = [Address2]
PRINTLINE5 = [POB]
PRINTLINE6 = [City] & ", " & [StateOrProvince] & " " & [PostalCode]


Print #1, " "
Print #1, (PRINTLINE1)
Print #1, (PRINTLINE2)
Print #1, (PRINTLINE3)
Print #1, (PRINTLINE6)
Print #1, " "
Close #1

NUMCOPY:

PauseTime = 2 ' Set duration.
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
DoEvents ' Yield to other processes.
Loop

Message = "Enter the number of copies"
NUMCOPIES = InputBox(Message, Title, NUMCOPIES + 1)
For counter = 1 To NUMCOPIES

PauseTime = 2 ' Set duration.
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
DoEvents ' Yield to other processes.
Loop


RetVal = Shell("C:\LABPRT.BAT") ' PRINTS LABEL.
Next counter

Exit_PRINTLABEL_Click:
Exit Sub

Err_PRINTLABEL_Click:
MsgBox Err.Description
Resume Exit_PRINTLABEL_Click

End Sub





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Data labels not printing BdgBill Charts and Charting in Excel 2 February 20th 06 12:54 PM
Labels not printing zip codes Michele Excel Discussion (Misc queries) 1 December 6th 05 09:54 PM
Printing labels from excel Linda Excel Discussion (Misc queries) 1 November 12th 05 05:11 PM
my merged address labels are only printing ONE page -- answer? Michelle Excel Discussion (Misc queries) 0 November 7th 05 09:04 AM
Printing a Pivot Table from code - Excel 2003 Newbie Excel Discussion (Misc queries) 4 January 5th 05 05:10 PM


All times are GMT +1. The time now is 07:25 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"