[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

amirstal

12/18/2006 2:37:00 PM

What is the code I need to write in order to:
1. Print the first page of an active worksheet?
2. Print a selected range (A1:B5 for example) of an active worksheet?

Thanks.

7 Answers

Tom Ogilvy

12/18/2006 2:49:00 PM

0

Activesheet.PrintOut From:=1, To:=1, _
Copies:=1, Collate:=True


Range("A1:B5").Printout

or selection.Printout

--
Regards,
Tom Ogilvy


"amirstal" wrote:

> What is the code I need to write in order to:
> 1. Print the first page of an active worksheet?
> 2. Print a selected range (A1:B5 for example) of an active worksheet?
>
> Thanks.
>
>

Don Guillett

12/18/2006 2:50:00 PM

0

1 1st page of active workBOOK
sheet1.printout
2
activesheet.range("a1:b5").printout
--
Don Guillett
SalesAid Software
dguillett1@austin.rr.com
"amirstal" <amirstal@yahoo.com> wrote in message
news:1166452596.351832.279360@n67g2000cwd.googlegroups.com...
> What is the code I need to write in order to:
> 1. Print the first page of an active worksheet?
> 2. Print a selected range (A1:B5 for example) of an active worksheet?
>
> Thanks.
>


Mike Fogleman

12/18/2006 3:02:00 PM

0

1.
ActiveWindow.SelectedSheets.PrintOut From:=1, To:=1, Copies:=1

2.
Range("A1:B5").Select
Selection.PrintOut Copies:=1

Mike F
"amirstal" <amirstal@yahoo.com> wrote in message
news:1166452596.351832.279360@n67g2000cwd.googlegroups.com...
> What is the code I need to write in order to:
> 1. Print the first page of an active worksheet?
> 2. Print a selected range (A1:B5 for example) of an active worksheet?
>
> Thanks.
>


amirstal

12/18/2006 3:08:00 PM

0

Thanks. That works perfectly.
Can I also make the code choose a specific printer to print from? I
want to direct the prints to a different printer than the default...



Tom Ogilvy wrote:
> Activesheet.PrintOut From:=1, To:=1, _
> Copies:=1, Collate:=True
>
>
> Range("A1:B5").Printout
>
> or selection.Printout
>
> --
> Regards,
> Tom Ogilvy
>
>
> "amirstal" wrote:
>
> > What is the code I need to write in order to:
> > 1. Print the first page of an active worksheet?
> > 2. Print a selected range (A1:B5 for example) of an active worksheet?
> >
> > Thanks.
> >
> >

amirstal

12/18/2006 4:23:00 PM

0

Thanks.
I could not get it to work.
This is how I tried:

Sub PrintBlotter()
'
' PrintBlotter Macro
' Macro recorded 12/18/2006 by Reuters LTD
'
Print Application.ActivePrinter
//IDB-NY509-04-TRADER-4600C
ActiveSheet.PrintOut From:=1, To:=1, Copies:=1, Collate:=True
'
End Sub

But I got the following message:
Compile error:
Method not valid without suitable object.

Thanks,

Amir
Tom Ogilvy wrote:
> Select the printer you want.
>
> then in the immediate window to
>
> ? application.ActivePrinter
>
> for example:
> ? application.ActivePrinter
> \\ARDAPS01\1D373C on Ne03:
>
> Now use this string to set the activeprinter (of course capture the default
> and set it back after printing).
>
> --
> Regards,
> Tom Ogilvy
>
>
> "amirstal" wrote:
>
> > Thanks. That works perfectly.
> > Can I also make the code choose a specific printer to print from? I
> > want to direct the prints to a different printer than the default...
> >
> >
> >
> > Tom Ogilvy wrote:
> > > Activesheet.PrintOut From:=1, To:=1, _
> > > Copies:=1, Collate:=True
> > >
> > >
> > > Range("A1:B5").Printout
> > >
> > > or selection.Printout
> > >
> > > --
> > > Regards,
> > > Tom Ogilvy
> > >
> > >
> > > "amirstal" wrote:
> > >
> > > > What is the code I need to write in order to:
> > > > 1. Print the first page of an active worksheet?
> > > > 2. Print a selected range (A1:B5 for example) of an active worksheet?
> > > >
> > > > Thanks.
> > > >
> > > >
> >
> >

Tom Ogilvy

12/18/2006 4:47:00 PM

0

Sub PrintBlotter()
'
' PrintBlotter Macro
' Macro recorded 12/18/2006 by Reuters LTD
'
' capture current default
s = Application.ActivePrinter
' set it to the desired printer
Application.ActivePrinter = _
"//IDB-NY509-04-TRADER-4600C"
' Print out
ActiveSheet.PrintOut From:=1, To:=1, Copies:=1, Collate:=True
' Restore the default
Application.ActivePrinter = s
End Sub

Would be my best guess based on what you show.

--
Regards,
Tom Ogilvy


"amirstal" wrote:

> Thanks.
> I could not get it to work.
> This is how I tried:
>
> Sub PrintBlotter()
> '
> ' PrintBlotter Macro
> ' Macro recorded 12/18/2006 by Reuters LTD
> '
> Print Application.ActivePrinter
> //IDB-NY509-04-TRADER-4600C
> ActiveSheet.PrintOut From:=1, To:=1, Copies:=1, Collate:=True
> '
> End Sub
>
> But I got the following message:
> Compile error:
> Method not valid without suitable object.
>
> Thanks,
>
> Amir
> Tom Ogilvy wrote:
> > Select the printer you want.
> >
> > then in the immediate window to
> >
> > ? application.ActivePrinter
> >
> > for example:
> > ? application.ActivePrinter
> > \\ARDAPS01\1D373C on Ne03:
> >
> > Now use this string to set the activeprinter (of course capture the default
> > and set it back after printing).
> >
> > --
> > Regards,
> > Tom Ogilvy
> >
> >
> > "amirstal" wrote:
> >
> > > Thanks. That works perfectly.
> > > Can I also make the code choose a specific printer to print from? I
> > > want to direct the prints to a different printer than the default...
> > >
> > >
> > >
> > > Tom Ogilvy wrote:
> > > > Activesheet.PrintOut From:=1, To:=1, _
> > > > Copies:=1, Collate:=True
> > > >
> > > >
> > > > Range("A1:B5").Printout
> > > >
> > > > or selection.Printout
> > > >
> > > > --
> > > > Regards,
> > > > Tom Ogilvy
> > > >
> > > >
> > > > "amirstal" wrote:
> > > >
> > > > > What is the code I need to write in order to:
> > > > > 1. Print the first page of an active worksheet?
> > > > > 2. Print a selected range (A1:B5 for example) of an active worksheet?
> > > > >
> > > > > Thanks.
> > > > >
> > > > >
> > >
> > >
>
>

amirstal

12/18/2006 5:09:00 PM

0

Still not working...

I get the following message:
Run-time error '1004':
Method 'ActivePrinter' of object' _Application' failed

and when I hit debug, this whole line is yellow:
Application.ActivePrinter = "//IDB-NY509-04-TRADER-4600C"


Thanks again, Amir.



Tom Ogilvy wrote:
> Sub PrintBlotter()
> '
> ' PrintBlotter Macro
> ' Macro recorded 12/18/2006 by Reuters LTD
> '
> ' capture current default
> s = Application.ActivePrinter
> ' set it to the desired printer
> Application.ActivePrinter = _
> "//IDB-NY509-04-TRADER-4600C"
> ' Print out
> ActiveSheet.PrintOut From:=1, To:=1, Copies:=1, Collate:=True
> ' Restore the default
> Application.ActivePrinter = s
> End Sub
>
> Would be my best guess based on what you show.
>
> --
> Regards,
> Tom Ogilvy
>
>
> "amirstal" wrote:
>
> > Thanks.
> > I could not get it to work.
> > This is how I tried:
> >
> > Sub PrintBlotter()
> > '
> > ' PrintBlotter Macro
> > ' Macro recorded 12/18/2006 by Reuters LTD
> > '
> > Print Application.ActivePrinter
> > //IDB-NY509-04-TRADER-4600C
> > ActiveSheet.PrintOut From:=1, To:=1, Copies:=1, Collate:=True
> > '
> > End Sub
> >
> > But I got the following message:
> > Compile error:
> > Method not valid without suitable object.
> >
> > Thanks,
> >
> > Amir
> > Tom Ogilvy wrote:
> > > Select the printer you want.
> > >
> > > then in the immediate window to
> > >
> > > ? application.ActivePrinter
> > >
> > > for example:
> > > ? application.ActivePrinter
> > > \\ARDAPS01\1D373C on Ne03:
> > >
> > > Now use this string to set the activeprinter (of course capture the default
> > > and set it back after printing).
> > >
> > > --
> > > Regards,
> > > Tom Ogilvy
> > >
> > >
> > > "amirstal" wrote:
> > >
> > > > Thanks. That works perfectly.
> > > > Can I also make the code choose a specific printer to print from? I
> > > > want to direct the prints to a different printer than the default...
> > > >
> > > >
> > > >
> > > > Tom Ogilvy wrote:
> > > > > Activesheet.PrintOut From:=1, To:=1, _
> > > > > Copies:=1, Collate:=True
> > > > >
> > > > >
> > > > > Range("A1:B5").Printout
> > > > >
> > > > > or selection.Printout
> > > > >
> > > > > --
> > > > > Regards,
> > > > > Tom Ogilvy
> > > > >
> > > > >
> > > > > "amirstal" wrote:
> > > > >
> > > > > > What is the code I need to write in order to:
> > > > > > 1. Print the first page of an active worksheet?
> > > > > > 2. Print a selected range (A1:B5 for example) of an active worksheet?
> > > > > >
> > > > > > Thanks.
> > > > > >
> > > > > >
> > > >
> > > >
> >
> >