Set print area problem

  • Thread starter Thread starter Philip Reece-Heal
  • Start date Start date
P

Philip Reece-Heal

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
 
Hi Philip,

Try:

ActiveSheet.PageSetup.PrintArea = myprint.Address
 
How are your variables declared? If myprint is a range, try:
ActiveSheet.PageSetup.PrintArea = Range(myprint)


Mike F
 
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.
 
You are right, my mistake. I opened my mouth without testing it first.
 
Thanks Norman

You are a star

It worked a treat

Regards
Philip
 
Thanks to you both, that's cracked my problem.

Regards
Philip
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top