Consulting

Results 1 to 3 of 3

Thread: AllowBreakAcrossPages...

  1. #1

    AllowBreakAcrossPages...

    How can I set AllowBreakAcrossPages for an individual row in a table containing merged cells?
    I am unable to access the row objects of the rows collection in vba.
    However, I can change the property for individual rows through the GUI (Table > Table Properties... > Row).
    If I record it I get this:
    Selection.Tables(1).Rows.AllowBreakAcrossPages = True
    But if I run that, it applys it to all rows (as expected).
    My feeling is it can't be done in VBA, but the GUI does it some other way.
    Any ideas?
    Last edited by Aussiebear; 04-24-2023 at 05:07 AM. Reason: Adjusted the code tags

  2. #2
    This always happens to me...
    I have solved it!
    oCell.Range.Rows.AllowBreakAcrossPages = True
    Last edited by Aussiebear; 04-24-2023 at 05:07 AM. Reason: Adjusted the code tags

  3. #3
    VBAX Master
    Joined
    Feb 2011
    Posts
    1,480
    Location
    Adam,

    Well, that's why you can't trust a recorded macro. However, it will give you a hint of what's going on if you look at the Help on each item you don't understand.

    I don't know how you're setting your oCell.Range, but you could just as easily have used...

    Selection.Rows.AllowBreakAcrossPages
    Selection.Range.Rows.First.AllowBreakAcrossPages
    Selection.Range.Rows(1).AllowBreakAcrossPages

    etc etc...
    The important point is that the help file tells you the *property* .AllowBreakAcrossPages can be applied to both the .Rows collection (which does *not* necessarily mean *all* the rows of a given table), or a Row object (which could be a single item of the given .Rows collection, whether you give a specific index like .Rows(1) or .Rows(3) or use the .First or .Last items, like .Rows.First or .Rows.Last).

    Hope that helps clarify what's going on. In terms of the recorded macro... if you notice what's going on in the background when you're in that dialog, when you click things like "next column" or "next row" you'll see the selection change. My guess is that Microsoft decided not to include those actions in the recorded macro for a number of reasons, and just decided to throw the whole thing together into the entire table (individual rows/columns can be difficult to describe in certain kinds of non-standard tables-- so any recorded macro trying to deal with that would in all likelihood blow up... so they stick to just the simplest way to describe the Selection).

Posting Permissions

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