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

Creating 2 print jobs as once using printer object

Status
Not open for further replies.

UncleCake

Technical User
Feb 4, 2002
355
US
Can I create 2 print jobs at once using the printer object? Is there a different method?

-Uncle Cake
 

I ran a test yesterday on a very simular question as this and I can say you can't with code like this ...
[tt]
Dim P1 As Printer
Dim P2 As Printer
Set P1 = Printer
Set P2 = Printer
P1.Print "1st Printer 1st Line"
P2.Print "2nd Printer 1st Line"
P1.Print "1st Printer 2nd Line"
P2.Print "2nd Printer 2nd Line"
P1.EndDoc
P2.EndDoc
[/tt]

It all prints on one page. Does anyone know of another method to try?

Good Luck

 


I believe the Print method is only available for the default printer so you'd have to toggle back and forth setting the Printer object to the printer to use. Something like:

Dim P1 As Printer
Dim P2 As Printer

' Get first two printers
For p = 0 To Printers.Count - 1
If p = 0 Then
Set P1 = Printers(p)
ElseIf p = 1 Then
Set P2 = Printers(p)
End If
Next

MsgBox P1.DeviceName & " / " & P2.DeviceName

Set Printer = P1
Printer.Print "Test 1st Printer 1st Line"
Set Printer = P2
Printer.Print "Test 2nd Printer 1st Line"
Set Printer = P1
Printer.Print "Test 1st Printer 2nd Line"
Set Printer = P2
Printer.Print "Test 2nd Printer 2nd Line"
Set Printer = P1
Printer.EndDoc
Set Printer = P2
Printer.EndDoc


Although the Print method sends a page break with the text, you could probably fool around with it and disable that feature...



Mark
 
Thanks guys for your suggestions. I tried to work with both of your suggestions, but I just can't figure out what to do.

As soon as Printer.Print is ran the print job starts spooling. Us you know, using the P1 and P2 actually sends the job to the two different printers. I am not sure what to do. I you have any other suggestions I would love to here them.

-Uncle Cake
 

The only other suggestion I can think of is to use string variables and load up these string with everything you want to print then use a single print statement to print the variables contents.
[tt]
Dim P1 As String, P2 As String
P1 = "1st Printer 1st Line" & vbNewLine
P2 = "2nd Printer 1st Line" & vbNewLine
P1 = "1st Printer 2nd Line"
P2 = "2nd Printer 2nd Line"
Printer.Print P1
Printer.NewPage
Printer.Print P2
Printer.EndDoc
[/tt]

Good Luck

 
Yeah, why must they exist as "print jobs" until you are actually ready to send them to the printer?

It is not clear whether you are just creating two documents at the same time or if you want to access two different printers.

The most recent message from vb5prgrmr implies one printer and two documents, in which case I agree that it would be better to just keep them as strings and not mess with Print until the documents are complete.

 
What I am trying to do is filter through a lot of records that contain customer over due balances, which are in a Btrieve database, so there isn't a real easy SQL statement that can be generated.

Therefore, I am creating a summary of each customers, which looks like a text file when printed. At the same time I want to create invoices that are sent to the customer. The report ends up being about 250 pages with 80 lines per page and another couple hundred in invoices. Therefore, I don't think that creating a string will solve my problem.

I could loop through the records twice, but I will be looping through the records twice and data could change and it isn't what I would consider efficient.

I hope that clears up what I am explicitly doing.

-Uncle Cake
 
I suppose you might be able to print the job to a file ( say, in Postscript format ), then print that file to 2 different printers.

Robert
 
TheVampiere,

It needs to go to one printer, which is in the area of the person running the program. I have thought of putting this in a text file using fso, print it, and then kill it, but I was trying to stay away from that.

-Uncle Cake

 

So then you could use a couple of RTB's and format the output if you like and that would solve the problem of files. Also if you are worried about how many characters a string can hold VB's help says ...
[tt]
String Data Type


There are two kinds of strings: variable-length and fixed-length strings.

A variable-length string can contain up to approximately 2 billion (2^31) characters.


A fixed-length string can contain 1 to approximately 64K (2^16) characters.
Note A Public fixed-length string can't be used in a class module.

The codes for String characters range from 0–255. The first 128 characters (0–127) of the character set correspond to the letters and symbols on a standard U.S. keyboard. These first 128 characters are the same as those defined by the ASCII character set. The second 128 characters (128–255) represent special characters, such as letters in international alphabets, accents, currency symbols, and fractions. The type-declaration character for String is the dollar sign ($).

[/tt]

so if you think you are going to go beyond that then maybe the RTB's would not be a good idea either since I believe their limit is about the same.

Good Luck

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top