Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Basic VBA Question

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.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Basic VBA Question

1 1st page of active workBOOK
sheet1.printout
2
activesheet.range("a1:b5").printout
--
Don Guillett
SalesAid Software

"amirstal" wrote in message
oups.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.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Basic VBA Question

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

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

Mike F
"amirstal" wrote in message
oups.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.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Basic VBA Question

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.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Basic VBA Question

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.







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Basic VBA Question

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.







Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Very basic VBA question. Cerberus Excel Discussion (Misc queries) 1 July 21st 08 04:30 PM
Basic question plittle Excel Discussion (Misc queries) 1 May 23rd 06 03:49 PM
Basic VBA question... mattsvai[_7_] Excel Programming 8 February 3rd 06 07:53 PM
Basic question hshayh0rn Excel Programming 10 December 28th 05 08:35 PM
Basic VBA question Henrik[_2_] Excel Programming 2 October 25th 03 12:23 AM


All times are GMT +1. The time now is 12:51 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"