+ Reply to Thread
Results 1 to 4 of 4

[SOLVED] Help - Error: Unable to set the PrintArea property of the PageSetup class

  1. #1
    Marie J-son
    Guest

    [SOLVED] Help - Error: Unable to set the PrintArea property of the PageSetup class

    Happy New Year to you all!

    I get Runtime error '1004': "Unable to set the PrintArea property of the
    PageSetup class" at the line below starting with "Sheet1.PageSetup.PrintArea
    =" as noted by "error" below.

    Do any of you see any obvious error I done with the code? Could it be caused
    by not having the right window active?
    Here is the extract from the code:
    ....
    With Application.CommandBars.FindControl(id:=182)
    If .State = msoButtonDown Then .Execute
    End With
    Application.ThisWorkbook.Windows(ThisWorkbook.Name).View =
    xlPageBreakPreview '
    Sheet1.PageSetup.PrintArea =
    Sheet1.Range("A1:O1450").SpecialCells(xlCellTypeVisible).Address '
    < ---_H_E_R_E_
    ....

    The code is initated by a button event in an UserForm procedure 'Sub
    CommandButton1_Click' and after several code procedures this happen in the
    end. All I want is to hide rows and show others in sheet1(codename).

    At first I thougt it was caused by to many signs (>256), but it was just
    this address: $A$1:$O$369,$A$514:$O$801,$A$946:$O$1231,$A$1375:$O$1450
    Any comments?

    /Regards



  2. #2
    Tom Ogilvy
    Guest

    Re: Help - Error: Unable to set the PrintArea property of the PageSetup class

    I pasted your range into the print_area refersto box and saved it. then
    went back and looked at it. It was stored with the sheet name as shown. I
    also checked the length.
    ? len("='Sheet1 (2)'!$A$1:$O$369,'Sheet1 (2)'!$A$514:$O$801,'Sheet1
    (2)'!$A$946:$O$1231,'Sheet1 (2)'!$A$1375:$O$1450")
    109
    If your sheet name is long, then length could be the problem.

    --
    Regards,
    Tom Ogilvy


    "Marie J-son" <[email protected]> wrote in message
    news:[email protected]...
    > Happy New Year to you all!
    >
    > I get Runtime error '1004': "Unable to set the PrintArea property of the
    > PageSetup class" at the line below starting with

    "Sheet1.PageSetup.PrintArea
    > =" as noted by "error" below.
    >
    > Do any of you see any obvious error I done with the code? Could it be

    caused
    > by not having the right window active?
    > Here is the extract from the code:
    > ...
    > With Application.CommandBars.FindControl(id:=182)
    > If .State = msoButtonDown Then .Execute
    > End With
    > Application.ThisWorkbook.Windows(ThisWorkbook.Name).View =
    > xlPageBreakPreview '
    > Sheet1.PageSetup.PrintArea =
    > Sheet1.Range("A1:O1450").SpecialCells(xlCellTypeVisible).Address '
    > < ---_H_E_R_E_
    > ...
    >
    > The code is initated by a button event in an UserForm procedure 'Sub
    > CommandButton1_Click' and after several code procedures this happen in the
    > end. All I want is to hide rows and show others in sheet1(codename).
    >
    > At first I thougt it was caused by to many signs (>256), but it was just
    > this address: $A$1:$O$369,$A$514:$O$801,$A$946:$O$1231,$A$1375:$O$1450
    > Any comments?
    >
    > /Regards
    >
    >




  3. #3
    Marie J-son
    Guest

    Re: Help - Error: Unable to set the PrintArea property of the PageSetup class

    Hi Tom, and thank you for your help.
    With your LEN operation you got 109 ist that right? Will it not be an error
    until (>256)? What can I do about it, do you think?

    /Regards



    "Tom Ogilvy" <[email protected]> skrev i meddelandet
    news:%231bB7%[email protected]...
    >I pasted your range into the print_area refersto box and saved it. then
    > went back and looked at it. It was stored with the sheet name as shown. I
    > also checked the length.
    > ? len("='Sheet1 (2)'!$A$1:$O$369,'Sheet1 (2)'!$A$514:$O$801,'Sheet1
    > (2)'!$A$946:$O$1231,'Sheet1 (2)'!$A$1375:$O$1450")
    > 109
    > If your sheet name is long, then length could be the problem.
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    > "Marie J-son" <[email protected]> wrote in message
    > news:[email protected]...
    >> Happy New Year to you all!
    >>
    >> I get Runtime error '1004': "Unable to set the PrintArea property of the
    >> PageSetup class" at the line below starting with

    > "Sheet1.PageSetup.PrintArea
    >> =" as noted by "error" below.
    >>
    >> Do any of you see any obvious error I done with the code? Could it be

    > caused
    >> by not having the right window active?
    >> Here is the extract from the code:
    >> ...
    >> With Application.CommandBars.FindControl(id:=182)
    >> If .State = msoButtonDown Then .Execute
    >> End With
    >> Application.ThisWorkbook.Windows(ThisWorkbook.Name).View =
    >> xlPageBreakPreview '
    >> Sheet1.PageSetup.PrintArea =
    >> Sheet1.Range("A1:O1450").SpecialCells(xlCellTypeVisible).Address '
    >> < ---_H_E_R_E_
    >> ...
    >>
    >> The code is initated by a button event in an UserForm procedure 'Sub
    >> CommandButton1_Click' and after several code procedures this happen in
    >> the
    >> end. All I want is to hide rows and show others in sheet1(codename).
    >>
    >> At first I thougt it was caused by to many signs (>256), but it was just
    >> this address: $A$1:$O$369,$A$514:$O$801,$A$946:$O$1231,$A$1375:$O$1450
    >> Any comments?
    >>
    >> /Regards
    >>
    >>

    >
    >




  4. #4
    Tom Ogilvy
    Guest

    Re: Help - Error: Unable to set the PrintArea property of the PageSetup class

    It is 109 based on my sheetname of Sheet1 (2). You would have to check it
    with your own sheetname to see if it is a problem. I don't know of another
    reason why it would be a problem, but that doesn't mean there isn't another
    reason.

    If your sheet name is in fact making it too long, you could shorten your
    sheet name.

    --
    Regards,
    Tom Ogilvy

    "Marie J-son" <[email protected]> wrote in message
    news:%[email protected]...
    > Hi Tom, and thank you for your help.
    > With your LEN operation you got 109 ist that right? Will it not be an

    error
    > until (>256)? What can I do about it, do you think?
    >
    > /Regards
    >
    >
    >
    > "Tom Ogilvy" <[email protected]> skrev i meddelandet
    > news:%231bB7%[email protected]...
    > >I pasted your range into the print_area refersto box and saved it. then
    > > went back and looked at it. It was stored with the sheet name as shown.

    I
    > > also checked the length.
    > > ? len("='Sheet1 (2)'!$A$1:$O$369,'Sheet1 (2)'!$A$514:$O$801,'Sheet1
    > > (2)'!$A$946:$O$1231,'Sheet1 (2)'!$A$1375:$O$1450")
    > > 109
    > > If your sheet name is long, then length could be the problem.
    > >
    > > --
    > > Regards,
    > > Tom Ogilvy
    > >
    > >
    > > "Marie J-son" <[email protected]> wrote in message
    > > news:[email protected]...
    > >> Happy New Year to you all!
    > >>
    > >> I get Runtime error '1004': "Unable to set the PrintArea property of

    the
    > >> PageSetup class" at the line below starting with

    > > "Sheet1.PageSetup.PrintArea
    > >> =" as noted by "error" below.
    > >>
    > >> Do any of you see any obvious error I done with the code? Could it be

    > > caused
    > >> by not having the right window active?
    > >> Here is the extract from the code:
    > >> ...
    > >> With Application.CommandBars.FindControl(id:=182)
    > >> If .State = msoButtonDown Then .Execute
    > >> End With
    > >> Application.ThisWorkbook.Windows(ThisWorkbook.Name).View =
    > >> xlPageBreakPreview '
    > >> Sheet1.PageSetup.PrintArea =
    > >> Sheet1.Range("A1:O1450").SpecialCells(xlCellTypeVisible).Address '
    > >> < ---_H_E_R_E_
    > >> ...
    > >>
    > >> The code is initated by a button event in an UserForm procedure 'Sub
    > >> CommandButton1_Click' and after several code procedures this happen in
    > >> the
    > >> end. All I want is to hide rows and show others in sheet1(codename).
    > >>
    > >> At first I thougt it was caused by to many signs (>256), but it was

    just
    > >> this address: $A$1:$O$369,$A$514:$O$801,$A$946:$O$1231,$A$1375:$O$1450
    > >> Any comments?
    > >>
    > >> /Regards
    > >>
    > >>

    > >
    > >

    >
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1