Problem using Printout method in Excel using VBA

Problem using Printout method in Excel using VBA

Post by rh » Fri, 18 Oct 1996 04:00:00



I am trying to use Excel 7.0 to generate a chart and then print it to
a file using a VB module. I am trying to do this without any user
interaction but when I try to use the 'object.Printout' method to print
to a file, I noticed that it does not take a filename as parameter but
expects a user to input the file name. I tried using the binder concept
and tried the following  
mybinder.Printout(what:=printvisiblesections,filename:="c:\test.ps") but
I got a run time error saying that the arguments are invalid.

Can someone tell me where I am going wrong?

Thanks in advance....

 
 
 

Problem using Printout method in Excel using VBA

Post by Peter JB Ki » Wed, 23 Oct 1996 04:00:00


I too am having problems using the PrintOut method in VBA

I am trying to print out the contents of a number of Dialogsheets

        Dialogsheets("A").PrintOut
        Dialogsheets("B").PrintOut
        Dialogsheets("C").PrintOut
but the code fails with the message 1004 method fails

The help text is not any assistance.

Replacing PrintOut with PrintPreview also fails, but if I step through
the code with the de*, PrintPreview works

Has anyone encountered this problem before?

--


  Edinburgh EH14 4AS, Scotland
Phone: (+44) 131 451 3433               Fax: (+44) 131 451 3431

 
 
 

Problem using Printout method in Excel using VBA

Post by RussTill » Thu, 24 Oct 1996 04:00:00



writes:

Quote:>I am trying to use Excel 7.0 to generate a chart and then print it to
>a file using a VB module. I am trying to do this without any user
>interaction but when I try to use the 'object.Printout' method to print
>to a file, I noticed that it does not take a filename as parameter but
>expects a user to input the file name. I tried using the binder concept
>and tried the following  
>mybinder.Printout(what:=printvisiblesections,filename:="c:\test.ps") but
>I got a run time error saying that the arguments are invalid.

>Can someone tell me where I am going wrong?

Here is the help text for PrintOut. Note that there are no "what:" or
"filename:" parameters. Let me know if you have questions. Good luck...
Russ

object.PrintOut(from, to, copies, preview)

Elements

The PrintOut method has the following object qualifier and named
arguments:

object

Required. The object to print.

from

Optional. The number of the page with which to start printing. If omitted,
printing starts at the beginning.

to

Optional. The number of the last page to print. If omitted, printing goes
to the last page.

copies

Optional. The number of copies to print. If omitted, one copy is printed.

preview

Optional. If True, Microsoft Excel invokes print preview before printing
the object. If False (or omitted) the object is printed immediately.

Remarks

"Pages" in the descriptions of from and to refers to printed pages -- not
overall pages in the sheet or workbook.

 
 
 

Problem using Printout method in Excel using VBA

Post by anyon » Fri, 25 Oct 1996 04:00:00



> I too am having problems using the PrintOut method in VBA

> I am trying to print out the contents of a number of Dialogsheets

>         Dialogsheets("A").PrintOut
>         Dialogsheets("B").PrintOut
>         Dialogsheets("C").PrintOut
> but the code fails with the message 1004 method fails

> The help text is not any assistance.

> Replacing PrintOut with PrintPreview also fails, but if I step through
> the code with the de*, PrintPreview works

> Has anyone encountered this problem before?

Try activating the sheet before you issue the PrintOut command.

I had a dialog sheet with a "Print" button, but the only way I could get
it to work was to close the dialog sheet then activate the worksheet
before using PrintOut.

 
 
 

Problem using Printout method in Excel using VBA

Post by Stephen Bulle » Tue, 29 Oct 1996 04:00:00


Hi Russ

One trick I have used is to use SendKeys to send the file name and an
enter character immediately before issuing the PrintOut.  This puts
the filename in the keyboard buffer, which the filename dialog uses.

Regards

Stephen Bullen, Excel MVP
http://ourworld.compuserve.com/homepages/Stephen_Bullen