+ Reply to Thread
Results 1 to 13 of 13

Remove Any Pagebreaks

  1. #1
    Registered User
    Join Date
    09-03-2007
    Posts
    51

    Remove Any Pagebreaks

    I'm using the this code to print some info out of an existing worksheet and I'd like to force excel to remove all pagebreaks, as the last column or two is always printed onto another page. Does anyone know how to programatically remove pagebreaks?

    Please Login or Register  to view this content.

  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good morning Gordon@work

    How about something like this :

    Please Login or Register  to view this content.
    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  3. #3
    Registered User
    Join Date
    09-03-2007
    Posts
    51

    Cells.PageBreak = xlPageBreakNone

    That causes an error saying: Unable to set the pagebreak property for the range class
    I tried another line which doesn't cause an error, I think because it's concerning the actual location of the break, but it just doesn't do anything at all: Columns("B:C").PageBreak = xlPageBreakNone

  4. #4
    Valued Forum Contributor
    Join Date
    04-11-2006
    Posts
    407
    If you just want it to print on one page maybe this would suffice:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    09-03-2007
    Posts
    51

    PageSetup method

    Thanks Ikaabod.
    It doesn't generate an error, but still prints the last column on a separate page.
    I've tried it from two other people's machines and we all have the same problem, this is infuriating.

  6. #6
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Hi Gordon@work

    Quote Originally Posted by Gordon@work
    That causes an error saying: Unable to set the pagebreak property for the range class
    That's strange. It works just fine for me.

    Sticking with the one liners, try this :
    Sub test()
    Please Login or Register  to view this content.
    (obviously, you replace "Sheet1 with your sheet name"

    HTH

    DominicB

  7. #7
    Registered User
    Join Date
    09-03-2007
    Posts
    51

    Application.Worksheets("Sheet1").ResetAllPageBreak s

    Hello dominicb,
    That function simply removes user-created page breaks, so nothing happened when I ran that line.
    These are Excel generated/automatic pagebreaks which are due to the width of these columns.

    Thank you for the suggestion anyway.

    -
    Gordon

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Can you post an example that illustrates the problem?

  9. #9
    Registered User
    Join Date
    09-03-2007
    Posts
    51

    Broken Page Example

    All forty or so tabs of about twenty workbooks are broken this way, and I need at least column E included on the same page. I just can't make it work.
    Attached Images Attached Images

  10. #10
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    I meant a spreadsheet, not a picture ...

  11. #11
    Registered User
    Join Date
    09-03-2007
    Posts
    51
    Sure. I wouldn't have thought of that!
    Attached Files Attached Files

  12. #12
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    OK, I don't see the problem. I set the print area to columns A:F, and did File > Page setup > Fit to: 1 page(s) wide by (blank) tall, and it printed fine.

  13. #13
    Registered User
    Join Date
    09-03-2007
    Posts
    51
    How strange. We have a new printer, maybe it has a dodgy driver or something then.
    Would anyone mind telling me if they can programatically move/remove the pagebreak at all please?

    Thank you all so much for your time.

    - Gordon
    Last edited by Gordon@work; 10-29-2007 at 01:07 AM.

+ 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