Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Trying to automate setting the print area on a sheet I use as a template and
am having problems. The section of code is: Set myprint = Range(mytop, mybot) myprint.Select ActiveSheet.PageSetup.PrintArea = myprint While the required area is selected on screen OK, the last line gives me a Run-time error '1004: Unable to set the PrintArea property of the PageSetup class. Have tried some alternatives but I'm stumped. Any help would be appreciated Regards Philip |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Philip,
Try: ActiveSheet.PageSetup.PrintArea = myprint.Address --- Regards, Norman "Philip Reece-Heal" wrote in message ... Trying to automate setting the print area on a sheet I use as a template and am having problems. The section of code is: Set myprint = Range(mytop, mybot) myprint.Select ActiveSheet.PageSetup.PrintArea = myprint While the required area is selected on screen OK, the last line gives me a Run-time error '1004: Unable to set the PrintArea property of the PageSetup class. Have tried some alternatives but I'm stumped. Any help would be appreciated Regards Philip |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How are your variables declared? If myprint is a range, try:
ActiveSheet.PageSetup.PrintArea = Range(myprint) Mike F "Philip Reece-Heal" wrote in message ... Trying to automate setting the print area on a sheet I use as a template and am having problems. The section of code is: Set myprint = Range(mytop, mybot) myprint.Select ActiveSheet.PageSetup.PrintArea = myprint While the required area is selected on screen OK, the last line gives me a Run-time error '1004: Unable to set the PrintArea property of the PageSetup class. Have tried some alternatives but I'm stumped. Any help would be appreciated Regards Philip |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Mike,
How are your variables declared? If myprint is a range, try: ActiveSheet.PageSetup.PrintArea = Range(myprint) If myprint is a range, then the expression Range(myprint) would generate an error. Additionally, the PrintArea property requires an address string. --- Regards, Norman |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You are right, my mistake. I opened my mouth without testing it first.
"Norman Jones" wrote in message ... Hi Mike, How are your variables declared? If myprint is a range, try: ActiveSheet.PageSetup.PrintArea = Range(myprint) If myprint is a range, then the expression Range(myprint) would generate an error. Additionally, the PrintArea property requires an address string. --- Regards, Norman |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Thanks Norman You are a star It worked a treat Regards Philip *** Sent via Developersdex http://www.developersdex.com *** |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks to you both, that's cracked my problem.
Regards Philip "Philip Reece-Heal" wrote in message ... Trying to automate setting the print area on a sheet I use as a template and am having problems. The section of code is: Set myprint = Range(mytop, mybot) myprint.Select ActiveSheet.PageSetup.PrintArea = myprint While the required area is selected on screen OK, the last line gives me a Run-time error '1004: Unable to set the PrintArea property of the PageSetup class. Have tried some alternatives but I'm stumped. Any help would be appreciated Regards Philip |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
set area in excel not giving me option to set print area? | Excel Discussion (Misc queries) | |||
File, print area, clear area, is not working | New Users to Excel | |||
Macro - Set Print Area for Changing Data Area | Excel Programming | |||
How do you turn off a print area for a page? (no print area) | Excel Discussion (Misc queries) | |||
In Excel print area setup problem with 2 different computers with. | Setting up and Configuration of Excel |