Printing from VB app 
Author Message
 Printing from VB app

I'm trying to use the printer object to print text to a printer.

I use SET PRINTER = PRINTERS(index) to select the printer for the specific
task, but how do I actually send the TEXT to the printer?

The doc I have says to use the "print" method, but when I try to use
PRINTER.PRINT BlahBlah I get an error saying the method is not found.

I am able to set the fontname, size, page orientation etc, .newpage ,
.endco, but not .print

This is VB6 with SP5 applied.

Any help would be appreciated...

Thanks,
Don



Sat, 05 Jun 2004 06:35:32 GMT  
 Printing from VB app

Quote:
> I'm trying to use the printer object to print text to a
printer.

> I use SET PRINTER = PRINTERS(index) to select the printer for
the specific
> task, but how do I actually send the TEXT to the printer?

> The doc I have says to use the "print" method, but when I try
to use
> PRINTER.PRINT BlahBlah I get an error saying the method is not
found.

> I am able to set the fontname, size, page orientation etc,
.newpage ,
> .endco, but not .print

> This is VB6 with SP5 applied.

Print is just not visible to intellisense--vestigial weirdness.
This code compiles:

  Printer.Print "Hi Bob"



Sat, 05 Jun 2004 06:35:24 GMT  
 Printing from VB app
OK, so it's just me... :-)

I tried that and now it works...

But I was also trying to use...
    with printer
        .fontname = ...
        .print "Blah"
    end with

And that choked on the .print saying method not found (at run time)

Oh well, working nw... thanks... I wa sure I tried that too... aarrgghh :-)


Quote:


> > I'm trying to use the printer object to print text to a
> printer.

> > I use SET PRINTER = PRINTERS(index) to select the printer for
> the specific
> > task, but how do I actually send the TEXT to the printer?

> > The doc I have says to use the "print" method, but when I try
> to use
> > PRINTER.PRINT BlahBlah I get an error saying the method is not
> found.

> > I am able to set the fontname, size, page orientation etc,
> .newpage ,
> > .endco, but not .print

> > This is VB6 with SP5 applied.

> Print is just not visible to intellisense--vestigial weirdness.
> This code compiles:

>   Printer.Print "Hi Bob"



Sat, 05 Jun 2004 07:07:18 GMT  
 Printing from VB app
This is a common problem when using the With statement. I usually try to
avoid calling "methods" inside of a With. Properties don't seem to have this
problem. You may notice that the Line method also has these problems. There
is a way around it, by just re-using the object name inside of the With
statement.

Example:
    With Printer
        .Font.Name = ...
        .Font.Size = ...
        Printer.Print "Blah"
    End With

HTH,
Rocky Clark (Kath-Rock Software)


Quote:
> OK, so it's just me... :-)

> I tried that and now it works...

> But I was also trying to use...
>     with printer
>         .fontname = ...
>         .print "Blah"
>     end with

> And that choked on the .print saying method not found (at run time)

> Oh well, working nw... thanks... I wa sure I tried that too... aarrgghh
:-)





> > > I'm trying to use the printer object to print text to a
> > printer.

> > > I use SET PRINTER = PRINTERS(index) to select the printer for
> > the specific
> > > task, but how do I actually send the TEXT to the printer?

> > > The doc I have says to use the "print" method, but when I try
> > to use
> > > PRINTER.PRINT BlahBlah I get an error saying the method is not
> > found.

> > > I am able to set the fontname, size, page orientation etc,
> > .newpage ,
> > > .endco, but not .print

> > > This is VB6 with SP5 applied.

> > Print is just not visible to intellisense--vestigial weirdness.
> > This code compiles:

> >   Printer.Print "Hi Bob"



Sat, 05 Jun 2004 07:18:37 GMT  
 Printing from VB app
hmm, that's a good "trick" to know.. properties, yes; methods, no :-)

Thanks,

Don


Quote:
> This is a common problem when using the With statement. I usually try to
> avoid calling "methods" inside of a With. Properties don't seem to have
this
> problem. You may notice that the Line method also has these problems.
There
> is a way around it, by just re-using the object name inside of the With
> statement.

> Example:
>     With Printer
>         .Font.Name = ...
>         .Font.Size = ...
>         Printer.Print "Blah"
>     End With

> HTH,
> Rocky Clark (Kath-Rock Software)



> > OK, so it's just me... :-)

> > I tried that and now it works...

> > But I was also trying to use...
> >     with printer
> >         .fontname = ...
> >         .print "Blah"
> >     end with

> > And that choked on the .print saying method not found (at run time)

> > Oh well, working nw... thanks... I wa sure I tried that too... aarrgghh
> :-)





> > > > I'm trying to use the printer object to print text to a
> > > printer.

> > > > I use SET PRINTER = PRINTERS(index) to select the printer for
> > > the specific
> > > > task, but how do I actually send the TEXT to the printer?

> > > > The doc I have says to use the "print" method, but when I try
> > > to use
> > > > PRINTER.PRINT BlahBlah I get an error saying the method is not
> > > found.

> > > > I am able to set the fontname, size, page orientation etc,
> > > .newpage ,
> > > > .endco, but not .print

> > > > This is VB6 with SP5 applied.

> > > Print is just not visible to intellisense--vestigial weirdness.
> > > This code compiles:

> > >   Printer.Print "Hi Bob"



Sat, 05 Jun 2004 08:09:20 GMT  
 Printing from VB app
Well, not exactly.

Methods are ok to use in a With-End With block. It's just that the Print
method is a special case that doesn't work like the others.

--
Tim Rude


(remove NOSPAM. for correct email address)

[Please reply via the newsgroup so all can benefit]


Quote:
> hmm, that's a good "trick" to know.. properties, yes; methods, no :-)

> Thanks,

> Don



> > This is a common problem when using the With statement. I usually try to
> > avoid calling "methods" inside of a With. Properties don't seem to have
> this
> > problem. You may notice that the Line method also has these problems.
> There
> > is a way around it, by just re-using the object name inside of the With
> > statement.

> > Example:
> >     With Printer
> >         .Font.Name = ...
> >         .Font.Size = ...
> >         Printer.Print "Blah"
> >     End With

> > HTH,
> > Rocky Clark (Kath-Rock Software)



> > > OK, so it's just me... :-)

> > > I tried that and now it works...

> > > But I was also trying to use...
> > >     with printer
> > >         .fontname = ...
> > >         .print "Blah"
> > >     end with

> > > And that choked on the .print saying method not found (at run time)

> > > Oh well, working nw... thanks... I wa sure I tried that too...
aarrgghh
> > :-)





> > > > > I'm trying to use the printer object to print text to a
> > > > printer.

> > > > > I use SET PRINTER = PRINTERS(index) to select the printer for
> > > > the specific
> > > > > task, but how do I actually send the TEXT to the printer?

> > > > > The doc I have says to use the "print" method, but when I try
> > > > to use
> > > > > PRINTER.PRINT BlahBlah I get an error saying the method is not
> > > > found.

> > > > > I am able to set the fontname, size, page orientation etc,
> > > > .newpage ,
> > > > > .endco, but not .print

> > > > > This is VB6 with SP5 applied.

> > > > Print is just not visible to intellisense--vestigial weirdness.
> > > > This code compiles:

> > > >   Printer.Print "Hi Bob"



Sat, 05 Jun 2004 12:44:58 GMT  
 Printing from VB app
But of  course... oh vay.. Ya gotta love Billy-ware... :-)

Oh well, that's a pretty small idiosyncracy to remember...

Thanks all who helped... :-)

Don


Quote:
> Well, not exactly.

> Methods are ok to use in a With-End With block. It's just that the Print
> method is a special case that doesn't work like the others.

> --
> Tim Rude


> (remove NOSPAM. for correct email address)

> [Please reply via the newsgroup so all can benefit]



> > hmm, that's a good "trick" to know.. properties, yes; methods, no :-)

> > Thanks,

> > Don



> > > This is a common problem when using the With statement. I usually try
to
> > > avoid calling "methods" inside of a With. Properties don't seem to
have
> > this
> > > problem. You may notice that the Line method also has these problems.
> > There
> > > is a way around it, by just re-using the object name inside of the
With
> > > statement.

> > > Example:
> > >     With Printer
> > >         .Font.Name = ...
> > >         .Font.Size = ...
> > >         Printer.Print "Blah"
> > >     End With

> > > HTH,
> > > Rocky Clark (Kath-Rock Software)



> > > > OK, so it's just me... :-)

> > > > I tried that and now it works...

> > > > But I was also trying to use...
> > > >     with printer
> > > >         .fontname = ...
> > > >         .print "Blah"
> > > >     end with

> > > > And that choked on the .print saying method not found (at run time)

> > > > Oh well, working nw... thanks... I wa sure I tried that too...
> aarrgghh
> > > :-)





> > > > > > I'm trying to use the printer object to print text to a
> > > > > printer.

> > > > > > I use SET PRINTER = PRINTERS(index) to select the printer for
> > > > > the specific
> > > > > > task, but how do I actually send the TEXT to the printer?

> > > > > > The doc I have says to use the "print" method, but when I try
> > > > > to use
> > > > > > PRINTER.PRINT BlahBlah I get an error saying the method is not
> > > > > found.

> > > > > > I am able to set the fontname, size, page orientation etc,
> > > > > .newpage ,
> > > > > > .endco, but not .print

> > > > > > This is VB6 with SP5 applied.

> > > > > Print is just not visible to intellisense--vestigial weirdness.
> > > > > This code compiles:

> > > > >   Printer.Print "Hi Bob"



Sun, 06 Jun 2004 13:27:32 GMT  
 Printing from VB app

Hello Don,

My name is Lily. Thank you for using the Microsoft VB Newsgroups.

As I tested, the following code works.

Private Sub Command1_Click()

  Set Printer = Printers(0)

  Form1.Caption = Printer.DeviceName

  Printer.Print "ABC"

End Sub

Hope it helps. If you have any questions, please reply to this post.

Best Regards,

Lily Zheng

Microsoft Support

Want to know more? Check out the MSDN at msdn.microsoft.com or the Microsoft Knowledge Base at support.microsoft.com

This posting is provided "AS IS" with no warranties, and confers no rights. You assume all risk for your use. Copy right, 2001 Microsoft Corporation. All rights
reserved.



Mon, 07 Jun 2004 11:09:34 GMT  
 Printing from VB app
Lily, I have a question related to printing that no one seems able to
answer.  I am working with an Access Database from an app. I created in VB6.
I used the Data Control and the DataGrid to work with it.
Everything works fine,,,,,,,except for printing.  I don't want to use the
Report Tool to print my database. I would like to use the Printer Object.
But, I cannot find any information on how to do this.  I can print only a
portion of the DataGrid contents but, not all of it.
I would like to print the entire database. (oh, and my user wants to be able
to have a grid printed on paper with the data along with column headers
printed in it.
Any suggestions ?
james


Quote:

> Hello Don,

> My name is Lily. Thank you for using the Microsoft VB Newsgroups.

> As I tested, the following code works.

> Private Sub Command1_Click()

>   Set Printer = Printers(0)

>   Form1.Caption = Printer.DeviceName

>   Printer.Print "ABC"

> End Sub

> Hope it helps. If you have any questions, please reply to this post.

> Best Regards,

> Lily Zheng

> Microsoft Support

> Want to know more? Check out the MSDN at msdn.microsoft.com or the

Microsoft Knowledge Base at support.microsoft.com
Quote:

> This posting is provided "AS IS" with no warranties, and confers no

rights. You assume all risk for your use. Copy right, 2001 Microsoft
Corporation. All rights

- Show quoted text -

Quote:
> reserved.



Mon, 07 Jun 2004 12:23:26 GMT  
 Printing from VB app

Hi James,
I am wondering why you don?t want to use the Report tool while you have a relatively high quality requirement of the report. Report layout
and formatting is a very time-consuming work, and that?s the value of the Report tool. I suggest you solve the problem in using report
tool, rather than writing code to print undesirable report.

Best Regards,

Lily Zheng

Microsoft Support

Want to know more? Check out the MSDN at msdn.microsoft.com or the Microsoft Knowledge Base at support.microsoft.com

This posting is provided "AS IS" with no warranties, and confers no rights. You assume all risk for your use. Copy right, 2001 Microsoft Corporation. All rights
reserved.



Mon, 07 Jun 2004 20:21:58 GMT  
 Printing from VB app
Thanks for the reply Lily.  I guess the main reason I don't want to use the
Report Tool is to make the program a bit lighter in size.  I figure that
adding that would increase the size of the program. And on top of that
I also figure that it would not have all of the capabilities I need to print
the kind of forms (with content from the database) that I need.
I will research using the Report Tool more. Maybe I will change my mind.
Thanks again.
james



Quote:

> Hi James,
> I am wondering why you don?t want to use the Report tool while you have a

relatively high quality requirement of the report. Report layout
Quote:
> and formatting is a very time-consuming work, and that?s the value of the

Report tool. I suggest you solve the problem in using report
Quote:
> tool, rather than writing code to print undesirable report.

> Best Regards,

> Lily Zheng

> Microsoft Support

> Want to know more? Check out the MSDN at msdn.microsoft.com or the

Microsoft Knowledge Base at support.microsoft.com
Quote:

> This posting is provided "AS IS" with no warranties, and confers no

rights. You assume all risk for your use. Copy right, 2001 Microsoft
Corporation. All rights
Quote:
> reserved.



Tue, 08 Jun 2004 03:06:48 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. print from VB app to some other app????help

2. Question about printing from VB app...

3. Question about printing from VB app...

4. Print output from console app in my VB app instead

5. print OLE object in my own VB App

6. print excel page from vb app

7. Printing TIFF files in VB app

8. How to print a size-constraint OLE object in my own VB App

9. PrintPreview - OLE server to add print preview capabilites to VB 4.0 apps

10. Print a VB window from within the app???

11. Printing MS Word Documents from VB app

12. Print .DOC files from VB app

 

 
Powered by phpBB® Forum Software