View Single Post
  #5   Report Post  
Posted to microsoft.public.word.tables
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default How do I lock a table (no more rows at bottom)?

There's nothing general you can do that will work regardless of
whether any particular table has merged cells or not. If you know with
absolute certainty what your table looks like (because you set it up
in a template and don't let anyone alter it), then you can program to
that specific circumastance. Instead of checking Rows.Count and
Columns.Count, check for the specific cell coordinates of cell C.

You would also want to start the event handler with a check for
whether the ActivDocument.AttachedTemplate is the one that contains
the table; if not, immediately Exit Sub. That will take care of the
possibility that a document based on your template and one based on a
different template are open at the same time (because the event
handler fires for all documents).

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Wed, 11 Nov 2009 14:30:09 -0800 (PST), Larry Sulky
wrote:

On Nov 4, 10:22*am, "Jay Freedman" wrote:
* * If Not ((thisRow = thisTable.Rows.Count) And _
* * * * * * (thisCol = thisTable.Columns.Count)) Then
* * * * Selection.MoveRight Unit:=wdCell
* * Else


Say, Jay, I adapted this code to something I'm doing and I've got a
problem. My table is two columns, and in the last two rows the cells
in the right column are merged:

+----+-----+
| A | |
+----+ B |
| C | |
+----+-----+

So the Selection.MoveRight Unit:=wdCell moves the selection from Cell
A to Cell B, then to Cell C, then back to Cell B. Cell A is at
(r1,c1), B is at (r1,c2), and C is at (r2,c1). There is no cell that
has the maximum row count and the maximum column count. That is, there
is no cell at (r2,c2). So the condition in the snippet above is true
for cell B both times the selection hits it, and on the second time,
the MoveRight creates a new row.

Any way to prevent that new row from being created?
TIA
---larry