Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Excel 2007 print problem

Many thanks for that Pascal and apologies for being so long in responding, I was actually
away. I apprecitae the time and effort you put into this and of course the successful
outcome!

Graham
papou wrote:
Ok got it.
Just pasted the whole code and tested, I have the same error.
Once you have selected the whole cells in your sheet (Cells.Select), the
Selection.Address returns "$1:$1048576"
This is what causes the error.
If your goal is actually to print all sheets of your workbook then I would
recommend you define the print area for each sheet.
Something like for instance:
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
ws.PageSetup.PrintArea = ws.UsedRange.Address
ws.PrintOut copies:=1
Next ws

HTH
Cordially
Pascal



"papou" a écrit dans le message
de news: ...
Graham
Your code (ActiveSheet.PageSetup.PrintArea = Selection.Address) works fine
for me in Excel 2007, so there should not be any need for modification at
this point.
Are there other sheets selected?
Are there any calls to word application? (in which case the expression
"Selection" could be misinterprated)
Try and check with :
MsgBox TypeName(Selection) = "Range"
If it returns True then it means the selection is correct.
One alternative could be to fully qualify objects, ie:
Dim Ws As Worksheet
Set Ws = ActiveWorkbook.Worksheets("Sheet1")
Ws.PageSetup.PrintArea = Selection.Address

Another point in MHO is that you are using too many selections in your
code.
Selection of cells should not be necessary, and you should consider
avoiding it.

HTH
Cordially
Pascal

"Graham H" a écrit dans le message de
news:
...
Hi Pascal,
Thanks for reply. This occurs when the procedure with a de-bug
window which says 'PrintArea' of object 'PageSetup' failed. As I said it
works perfectly fine in Exccel 2002, I just wondered what modification
was required for 2007.The code it is included in is
ActiveWindow.SelectedSheets.PrintOut Copies:=1
Cells.Select
ActiveSheet.PageSetup.PrintArea = Selection.Address
Range("A1").Select
Sheets("Commands").Select


Thanks for your comments.

Graham

papou wrote:
Hello Graham

There's obviously some hiccup with Selection.Address in your code.
What is the error message?
Does your selection contain any object?
Try and get what Selection.Address actually returns, for instance:
Debug.Print Selection.address
or
Msgbox Selection.Address

Cordially
Pascal

"Graham H" a écrit dans le message de
news: ...
Using a procedure which was originally created in Excel 2002 I am
getting an error at the following line when running the same procedure
on Excel 2007.

ActiveSheet.PageSetup.PrintArea = Selection.Address

I am at a loss as to why it comes out at this point and would value any
guidance.

Graham



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
Print problem in Excel 2007 Eric_G Excel Discussion (Misc queries) 0 November 3rd 09 04:31 PM
Footes - Automaticly print on every print job - Excel 2007 JohnH Excel Discussion (Misc queries) 1 August 21st 09 01:32 PM
Excel 2007 Query Wizard problem with Access 2007 extensions Showdad Excel Discussion (Misc queries) 0 December 4th 08 05:57 PM
excel 2007 won't print whole page TMac Excel Discussion (Misc queries) 0 April 2nd 08 08:41 PM
Print thru using EXCEL 2007 pcor New Users to Excel 4 December 14th 07 05:22 PM


All times are GMT +1. The time now is 02:06 AM.

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

About Us

"It's about Microsoft Excel"