Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Printer.Print Command (VB6)


Hey, I'm currently using the following code to print out information from a database:

Printer.Print "Name Age"
Do Until Rs.EOF
Printer.Print "" & rs.fields("Name") & " " & rs.fields("Age") & ""
Rs.MoveNext
Loop

However, as the entries under the "Name" field in the database are all different lengths, the resulting printout looks a bit of a mess. How would I modify or add to the above code to ensure a tabular format in the printout?

Thanking you in advance...




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
How Can I Change The Default Printer At Runtime To Use It With Printer.print Command?
Hi everyone,
I have a little application which uses printer.print command to do some print jobs, of course there are some other things that I print using Data Reports.
When my application starts, I think it instantiates printer object with the default printer (lx300). Once the application is started, there are some options that use printer.print, but there are options that use printer.print too but I need to print them in another printer (ip1000). I have a common dialog that lets me choose the printer, and when I choose ip1000 every printer.print call goes to lx300. I assume there's no way to "reinstantiate" printer object to print in ip1000.
Also, when I close my application ip1000 becomes my default printer. Does the common dialog can select a printer without changing the Windows default printer like Word, Excel. do?

Thanks a lot for your help

How Can I Change The Default Printer At Runtime To Use It With Printer.print Command?
Hi everyone,
I have a little application which uses printer.print command to do some print jobs, of course there are some other things that I print using Data Reports.
When my application starts, I think it instantiates printer object with the default printer (lx300). Once the application is started, there are some options that use printer.print, but there are options that use printer.print too but I need to print them in another printer (ip1000). I have a common dialog that lets me choose the printer, and when I choose ip1000 every printer.print call goes to lx300. I assume there's no way to "reinstantiate" printer object to print in ip1000.
Also, when I close my application ip1000 becomes my default printer. Does the common dialog can select a printer without changing the Windows default printer like Word, Excel. do?

Thanks a lot for your help

Printer.print Command With MSFlexGrid
Hi,
I am trying to use printer.print command to print all the rows and
columns on a MSFlexGrid control.
The problem I am having is if a row has "wordwrap" property, it shows up
on the form correctly but won't wrap on the printer.print command.



Any help is appreciated.

How Do We Print A File Through A Network Printer Using Command In VB? (Resolved)
Hi evrywan

Here's the scenario:

We are developing a system for a company which is using dot matrix printer. They require that the report be text-based, and can be fit into small papers. Hence, we'll go for text-based reports with ESC-P2 printer escape codes.

Problem is, this kind of report seems to require DOS printing in order for the printer to capture the printer code, because we tried to open a notepad and let user prints over it, the layout doesn't follow what as we desired (15 CPI or condensed printing etc)

If using DOS, we may as well just use "type filename.txt>\computernameprintername" to get it to print out at a network destination. So may I know how do we do that in VB?

Thanks for all of your attentions ^ ^



Edited by - amao on 5/5/2005 12:20:25 AM

Command Line To Print Postscipt File To Local Printer
Is there a command line I can use to print a postscript file to my local default printer?

Avoid Printer From Ejecting The Paper After The Last Line Printed? (VB - Printer.print)
how to stop the printer from ejecting the paper after the last line has printed?
assume i'm making an invoice for my small store, and i want to print the items my customer bought downward, so whether it's 1 item, or 5 items, or 100 items, i want the printer stop after the last item has printed ( plus my invoice's footer off course ). i am using VB 6, and 'printer.print' code to print and my printer is EPSON LX-300+. and my database is SQL Server 2000 Developer Edition. is there anyone can help? i really appreciate any help you offer

PS : i've been searching this forum and try all topics related to my issue but nothing's suitable for me...so if there's someone can be more specific, i would really appreciate it

VB6 - Print A Text File To A Remote Printer And My Default Printer
Please how can I get a text file located in my hard drive (C:) to print to my default printer and also print to a Remote Printer?

The remote printer is named "U288".

Any workable code snipet will be appreciated.

Thanks y'all.

Giftx.

How To Check The Printer On The Network Before Printer.print Method?
Hi,
I am trying to write code to be able to give user option to choose a
printer on the network before they can printer the job.

With printer.print method, VB will not prompt the printer on the
network.
It will only print to the default printer.

Is there a way to be able to choose the printer?



Thanks!

How To Print A Specific File To The Printer/network Printer
I want to print data which is entered in rich textbox. Also I want to set top,left,right and bottom margin of file........

How To Print Urdu Unicode Characters Using Printer.print Method ...??
Ive written a code for accepting input in text boxes in urd language and store it in access database and similarly i ca retrieve it back from the database and show it in the text boxe from the database in urdu language in vb6.0. But i cannot prin the same urdu unicode characters from the text boxes using th Printer.Print method, and if i do so i got ??????? (questio marks) printed instead of the urdu unicode characters. I eve tried the rich text boxe's selPrint method also but that als print the same ?????.
i wan to print the contents of the text boxes i.e unicod characters in urdu language.
Can anyone tell me how to do this as soon as possible ........??
Can anyone share with me the code for doing the above printing o unicode characters?

Waitin for the reply as earliest .......!!!

Print Error 486: Can’t Print Image To This Type Of Printer
Hey all
Has anyone seen this error when trying to initiate printform? I am trying to printform in a loop and it gives me this error. The printall subroutine has my printform code. It works perfectly the first time but when it tries to move to the previous record and then print that one I get this error. I searched for information but only found one suggestion where someone suggested putting a time delay in there. I tried that and it still would not print the second time. Help please.......
Thanks so much
Kim

Here is my code:

Code: Private Sub cmdPrintAllForms_Click()
    On Error GoTo SubErr
    Dim i As Integer
    Dim rs As ADODB.Recordset
    
    Set oConn = New ADODB.Connection
    oConn.Open frmSplash.sConn
  
    strSQL = "select * from tblAircraftWO where work_order_no = " & txtWorkOrderNo.Text
    
    Set rs = New ADODB.Recordset
    rs.Open strSQL, oConn, adOpenKeyset, adLockOptimistic
    
    i = rs.RecordCount
    
    rs.AbsolutePosition = txtCardNo.Text
     
    Do While Not rs.BOF
        PrintAll
        
        rs.MovePrevious
        If Not rs.BOF Then
        RetrieveRecords
        End if
    Loop
        
    If rs.BOF Then
        rs.MoveFirst
        MsgBox "You are at the beginning."
    End If
   
SubExit:
    Exit Sub
    
SubErr:
    MsgBox Err.Number & ": " & Err.Description
    Resume SubExit
End Sub

How To Print Urdu Unicode Characters Using Printer.print Method ...??
Ive written a code for accepting input in text boxes in urdu language and store it in access database and similarly i can retrieve it back from the database and show it in the text boxes from the database in urdu language in vb6.0. But i cannot print the same urdu unicode characters from the text boxes using the Printer.Print method, and if i do so i got ??????? (question marks) printed instead of the urdu unicode characters. I even tried the rich text boxe's selPrint method also but that also print the same ?????.
i wan to print the contents of the text boxes i.e unicode characters in urdu language.
Can anyone tell me how to do this as soon as possible ........??
Can anyone share with me the code for doing the above printing of unicode characters?

Waitin for the reply as earliest .......!!!

Printer Not Responding To Printer.Print --> Help Newbie
First... I am depressed like hell to get this to work.

Problem: I have an "Eltron 310" ID Card Printer. I am trying to do

Printer.PaintPicture IMG_ID,0,0 (where IMG_ID is a picture)
Printer.EndDoc

The above
--> Works with normal printer
--> Does not work with ID Card Printer. ID Printer doesn't even respond to the command, Printer.PaintPicture, nor does it respond to Printer.Print "some text"

PLEASE HELP. ANY CODE IS GREATLY APPRECIATED.

Thanks
Sreeni

Printer Not Responding To Printer.Print --> Help Newbie
First... I am depressed like hell to get this to work.

Problem: I have an "Eltron 310" ID Card Printer. I am trying to do

Printer.PaintPicture IMG_ID,0,0 (where IMG_ID is a picture)
Printer.EndDoc

The above
--> Works with normal printer
--> Does not work with ID Card Printer. ID Printer doesn't even respond to the command, Printer.PaintPicture, nor does it respond to Printer.Print "some text"

PLEASE HELP. ANY CODE IS GREATLY APPRECIATED.

Thanks
Sreeni

? Printer Should Print Your Current Printer - Correct?
I am right in assuming that if I run a standard .exe program and I pause it...then type in the Immediate window the following:


Code:
? Printer

then it should come up with the default printer name - correct? Please let me know if I'm wrong.
Thanks,

Stephen

Must Close Program To Print Using Printer.print
Hi,

Using VB 5.0 and find that I must close the VB program before the printer will actually print. I'm using printer.print. Do I need some control character at the end? Any ideas?


Thanks,
met12

How Do You Print Formatted Text With Printer.Print?
How do you print formatted text using Printer.Print?

Eg text in colour, underline & bold & stuff

How Can I Print A Graphic File Using Printer.Print?
I am trying to send text directly to the printer using printer.print but I was wondering if I could also send a small logo graphic as well. What would I need to do?

say my image is "Logo.jpg"

Guidelines For Form.Print And Printer.Print?
Hi,

Can somebody please provide some guidelines on when and where I can use the Form.Print and Printer.Print codes. I've just spent hours trying to understand what works and what doesn't I've tried to find information in the standard MS manuals and I have searched this site without much success.

Simply, I want to print out the value of some variables at various stages of program execution for debugging purposes. Actually there are many hundreds of values so I don't want to copy them from the screen onto paper manually.

Let's take a simple case

    Printer.Print "Hello"
    Printer.EndDoc

Seems straightforward and code like this is listed in many sources. It just would not work for me! The code would apparently execute but no printout appeared

This code was included in a Standard (.BAS) Module, but it just would not work.

I tried the same code in a Form subroutine and called it from the Form.Load event, but it still didn't work.

Finally, I called the same routine in the form from a Command Button - it worked - Hooray!

I put the subroutine back into the BAS module and called it from the same Command Button in the form but it no longer worked.

No error messages appeared anywhere


I found the same type of behavior with the Form.Print and associated codes.

Perhaps I'm being very dense here, but is this behaviour expected? If so, how can I print variable values from within .BAS modules?

Thank you to anybody who can shed light on this idiosyncratic behaviour.

Andy T.

System

VB6 SP5
CPU Athlon XP 2800+
Windows XP Home
Brother HL5040 laser printer (default)
 

Print Lines With Printer.print Code
Can anybody help me with code to print horizontal and vertical lines using the Printer.Print code?

thank you.

Print Problems Specifically Enddoc And Print Command
Hello, and welcome to my problem!

My code is below. My problem is this, it wont print, at all, sometimes when I shut the program down it will but not as it is here, or it sends an undefined error back when I hit the command button that holds this.

I just followed a tutorial I found on the net but not specific enough. please help.

Is there supposed to be a print icon with the other objects in the menu that holds the check boxes, list, comboboxes etc that I click and paste onto my form? If so were can I find it, if not who knows.


Private Sub Command1_Click()


Print

Printer.Print
Printer.Print
Printer.Print
Printer.Print
Printer.Print
Printer.Print
Printer.Print Spc(10),
Printer.Print Spc(10), "Selling Price", selltotal.Text, sellall.Text
Printer.Print Spc(10), "Item Cost", costtotal.Text, costall.Text
Printer.Print Spc(10), "Shipping", shiptotal.Text, shipall.Text
Printer.Print Spc(10), "Handling", handtotal.Text, handall.Text
Printer.Print Spc(10), "Other", othertotal.Text, otherall.Text
Printer.Print Spc(10),
Printer.Print Spc(10),
Printer.Print Spc(10),
Printer.Print Spc(10),
Printer.Print Spc(10), "Profit", profittotal.Text, profitall.Text
Printer.Print Spc(10),
Printer.Print Spc(10),
Printer.Print Spc(10),
Printer.NewPage
Printer.EndDoc

thank you ever so much

you should have seen what I could do on my PET

Print Command In Vb6 To Print A Range In An Excel Worksheetsheet
Thank you for you assistance in populating an excel sheet from a vb6 user form textbox.

I am now struggling to print the excel sheet from vb6 command button.

I can print the worksheet but it is blank as I cannot work out how to set the print range.

Assistance would be appreciated as, after hours of trying, I am about ready to scream!!

How To Printer.Print To Non Default Printer

I have a small app that I need to modify.  Basically it sends a report straight to the (default) printer by Printer.Print

Users want to print to their non-default printer, too.  I could change the default printer by Set Printer = another Printer and then get back to the original one, but is there a better way to do it?
Have fun.

---- Andy

Print.. Printer.Print ?? Ahh!!! Under Win Nt Server 4.0
Hi...
I have just installed windows nt server v4.0 as well as vb pro 6.0. Trying to use the printer command as follows:

printer.print = "Hello"
printer.EndDoc

This produces the printer icon near the time to appear. The only problem is that the printer does not print anything.. Performed a test print under printers folder in control pannel and it worked, But trying to print in vb will not work.. Tried 2 printers aswell.. Please help

"Printer.print && Printer.currentx/y"-question
Hello,

Im kinda a newby (not really), but i need some answers to newby questions...

I got a nice program wich outputs data on my form...
NOW, i want to print the information with my printer...

and i've read some stuff about it... and found the "Printer.print"-method the best solution...

SO, now I got some questions about it...
--> when i say "printer.currectx = 250", then where will the printer print my stuff??
- at 250 mm from the leftmargin
- at 250 mm form the paper
- at 250 pixels from the leftmargin
- at 250 pixels from the paper
- at somewhere else

What i'dd like is it be printed at 25 mm from the paper...

tnx anyway....

How Can Print To Local Printer Using "Printer.port"
Hi all, I have a local printer which is connected to one computer. I use the code printer.port which works well and prints to printer. But when i try to print from another computer which is a lan it gives the error "Bad file number".
How can i do this

VB 6.0 Printer.print
I have a report that i create by the printer.print command and I was asked if i can put a graphic on the report, is there a way to do that using the printer.print commands? I do not know how to create and use crystal reports in vb.

Thanks for any help.

Printer.Print
I want to print the line as:

"This is to inform that Mr. ABCD visited the site on 3/2/04."

My code looks some what like this:


Code:
Dim var1, var2

Printer.Print "This is to inform that Mr. " & var1 & "visited the site on " & var2
I want to set the Tab in such a way that it always takes equal space for var1 and var2. I mean if the length of var1 is defined to be 10 then, even if user enters value of var1 to be of 3 characters, the Tab Setting should not disturb. Even var2 should come at its right place.

Print Out To Printer
I want to print out some fields from a form.
How is the code for that ?

Printer.Print
Dear Users,

Sub_Printing( )
Printer.Print "Testing"
End Sub

It seems that, when i closed the application,the printer will only print the word out..Why it behaves like that. I just want it to be printed as i call the Sub_Print.

Any Solution?

Thanks & Regards;
KahFui

Printer.Print
Hello all,

Could you throw some light on the following code :

in NT/98/95 environment

Printer.print "Message"

was printing directly to default printer without problem

whereas same code in win 2000 environment is giving an error saying

"The instruction at "0x77f5069f" referenced memory at "0x00000048".The memory could not be read"

and it is terminating the application.


thanks
Kishan

How To Print To A Usb Printer In Dos?
Hi
How to print to a usb printer in dos?

Printer.Print
I want to print the line as:

"This is to inform that Mr. ABCD visited the site on 3/2/04."

My code looks some what like this:


Code:
Dim var1, var2

Printer.Print "This is to inform that Mr. " & var1 & "visited the site on " & var2


I want to set the Tab in such a way that it always takes equal space for var1 and var2. I mean if the length of var1 is defined to be 10 then, even if user enters value of var1 to be of 3 characters, the Tab Setting should not disturb. Even var2 should come at its right place.

Printer.print
I am trying to print 2/3 columns of data on a sheet with an equal spacing. Having played around with the currentX and Y values I can still only get one column. Can anyone help. Thanks in advance.

Printer.Print
I need to put a paper trail into an application. As the user enters information I need to print it, 1 line at a time. Is this even possible on a Ink Jet printer. We used to see this all the time back in the days of the dot matrix with the rollers. I can use VB6 to do Printer.Print but on my Ink Jet it doesn't print until I do a Printer.EndDoc. If it is impossible to do with the Ink Jet does anyone know of a way to do it if I got an old printer with a roller?

Thanks.

Printer.print Hoo Ha
I have code to print a page that allows space at the top for letterhead...10 printer.print " " statements.

All is well printing one page. But when I print a second page, it will not start 10 lines down, as the first page did. Rather, it will go a few lines more, which screws everything up. Why does it do this? Are there values being carried over from page to page that need to be cleared somehow? What am I missing?

Using Printer.Print
For Example "CUSTOMER: John Doe"

How would you print out CUSTOMER: in FontBold and FontSize 14 and then John Doe in ForeColor Red and FontItalic on the SAME LINE using Printer.Print

Printer.Print?
Can anyone point me to a good reference on how to set margins when sending text to the printer.

What I'm trying to do is send text from a richtext box to the printer. I have no problem getting it there but I can't seem to be able to figure out how to set the left, right, top and bottom margins. I have been able to move the left margin but I can't seem to be able to do much with the top margin.

I have tried printer.scaletop, printer.scaleleft, printer.scalewidth, printer.scaleheight, printer.currentX, printer.currentY and printer.scalemode.

I think the answer is in the use of these properties, but I can't seem to figure them out.

Mark

Printer.Print
Hello,

Is there a way to use Printer.Print to do something like this:

The paragraph is on this side. _________Another Field: Price
I want this paragraph's width to_________Another Field: Tax
be about 50% of the page and for _______Another Field: Total
the lines to wrap.

*underscore indicates spaces

Thanks in advance.

TtLai

Printer.Print
Printer.Print Tab(3); .lblOperationBC.Item(1).Caption; Tab; Tab; Tab; Printer.CurrentX; .lblOperationBC.Item(1).Caption

I am trying to line up a column to print badges the size of id cards

can anyone tell me how to get over to differents spots.

like if i want to print "hello world" tab over a bit and print "hello world" again

and the next line i want to print the same thing only with a number "1" instead of hello world. only i am doing it in a loop and need to make sure that i start the second column over far enouogh

Printer.Print.... How Come This...
Ok. Obviously I am a newbie at VB. Sort of.

I need to print directly to a port. Say... LPT1.

Here is what I have so far...

Public Function PrintLabels() As Boolean
Dim X As Printer
Dim sData As String

For Each X In Printers
If X.DeviceName = "Eltron" Then
Set Printer = X
Exit For
End If
Next

sData = "N" & Chr(10) & "A200,100,0,2,2,3,N," & _
Chr(34) & "HO HO HO" & Chr(34) & Chr(10) & "P1" & _
Chr(10)

With Printer
.Print sData
.NewPage
.EndDoc
End With
End Function

But when I try to send the data to the printer...

On the Printer.Print line

"Compile Error"
"Method or data member not found"

Any Ideas?

Thanks

Print To Printer
Dear All,

I've got a simple question for all of you. About print to printer. Hopefully, someone can answer my questions.

I have data in my database. I'd like to print them out to my printer directly without using any programs like using Crystal Report.
(Just like print to file (txt file), but this one, I'd like to print to printer).

Could anybody tell me how ???

Thx a lot,
Regards,
Wen Lie

Printer.print
hi,

im trying to use the printer.print method to print send text to the printer. the text only gets printed when i quit the program. is there any way of making it print immediatley so i can go on to print changes etc to the text?
cheers

Printer.print
To print using the printer object, the online help says to use the print method. But when I type in "printer." there isn't a print method in the pop-up list. So how do I print using the printer object?

About Printer.print
hi there.

can some1 pls help me with the Printer.Print in VB6. i'm
trying to print records from the database. i can only print
only the current information that is on the form. i want to
print all the information that corresponds with the person
on the form.

please help!!

best regards,
sbusiso

Printer.Print
Hi,all



I need help.



How to print on same position. Like Print(x,y) .......



Is that possible to be done.



Actually is used printer.print Word



But when i use tab or even string$, it's doesn't give a good result.



Regard and thank you





Hok sun

Print To A Printer
Hi all!
I need help to write one line command OnClick which will send text from txt box or label to a certaint printer.

Thanks

Printer.Print To PDF
In an app a programmer was changing the default printer to Adober PDF and using Printer.Print to create a PDF.  Is there any way I can avoid the Save As dialog that pops up when I print to the Adobe PDF printer other than using Send Keys?  Thanks. Swi

Try To Print Without A Printer
Im just wondering if someone presses print but they are not connected up to a printer will I need to have error handling code or will the vb program just act as if nothing happened.

Copyright 2005-08 www.BigResource.com, All rights reserved