I know the line of VBA I want to apply to my table is something like:
Selection.Tables(1).Rows.AllowBreakAcrossPages = False
but what I don't know is how to make sure the .AllowBreak... = false action is applied to the correct table when I'm not sure exactly on which line the in the document the table in question occurs, i.e. just because:
Selection.MoveDown Unit:=wdLine, Count:=26
works when I record the macro with an example doc it won't always work because in other docs the table won't necessarily be 26 lines down from the top.
What I do know though is that the table will always be the fourth table from the start of the doc (where the second table is nested inside the first table) and that this position also coincides with the table always being the first table after the first hard page break in the doc.
Guidance will be much appreciated.
Ken
select a particular table by VBA
-
- Panoramic Lounger
- Posts: 8225
- Joined: 25 Jan 2010, 09:09
- Location: retirement
-
- Administrator
- Posts: 78788
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: select a particular table by VBA
Use
ActiveDocument.Tables(3).Rows.AllowBreakAcrossPages = False
Although it is the fourth table, it counts as the third becaus one of the tables is nested.
ActiveDocument.Tables(3).Rows.AllowBreakAcrossPages = False
Although it is the fourth table, it counts as the third becaus one of the tables is nested.
Best wishes,
Hans
Hans
-
- Panoramic Lounger
- Posts: 8225
- Joined: 25 Jan 2010, 09:09
- Location: retirement
Re: select a particular table by VBA
That did the trick,
Ken
Ken