Results 1 to 3 of 3
  1. #1
    Lounger
    Join Date
    Jul 2006
    Location
    New York City, New York, USA
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Page Breaks in VBA (2003)

    Hi,
    A user of mine downloads reports from a database that puts between 1 and 6 tables on each worksheet.
    I wrote a simple macro for her that inserts a page break after each table based on text in the bottom row, so that each table prints on a different page. (They vary in height, but always fit on a single page.)
    She would like it modified so that, wherever possible, it fits two tables on a page.
    The tables vary somewhat in width from one download session to the next. The sheets are always set to print 1 page wide. The "pages tall" box is left blank. So the percentage of normal size that it's printed at will vary.
    I can think of no way to do this but to:
    A) set the page breaks one at a time in descending order,
    and then
    [img]/forums/images/smilies/cool.gif[/img] after each new break, check for the location of the next break after that one, to see if it falls below the next two tables, in which case I'd put both of them on the same sheet.
    But, being not terribly familiar with pagebreaks, I don't know whether this is even achievable.

    So my questions are: is there a better way to do this? And if not, is it doable at all?
    Thanks very much

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Page Breaks in VBA (2003)

    If you search for hpagebreaks, you'll find several examples of manipulating page breaks in VBA.

  3. #3
    Lounger
    Join Date
    Jul 2006
    Location
    New York City, New York, USA
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Page Breaks in VBA (2003)

    Thanks very much. Looks like hpagebreaks(x).location.address will do the trick.

Posting Permissions

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