Stop adding rows to end of table

O

olwenh

Hi,

I'm creating a form. I have a section break and an unprotected section with
a table in it as this section may (or may not) need a lot of text. The next
section is protected.

I want the users to move around the form using the tab key, but when they
are in the unprotected table, the tab key adds another line to the end of the
table.

Does anyone know how to stop this?

Thanks
 
D

Doug Robbins - Word MVP

If you put the table inside a TextBox, while pressing the tab key may add
another row, it will not be visible and the user will soon get the message.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
O

olwenh

Hi,

I've tried that but it doesn't solve the problem. The reason I need to use
an unprotected section with a table in it, is because I need the cell of the
table where the text is written to grow & shrink according to the amount of
text entered. By putting a text box around it, the box size is fixed.

Any other ideas?

Thanks
 
H

Helmut Weber

Hi olwenh,

if it has to be, you may define a global variable R
of allowed rows for a table,
also a global table object T.
And in addition a selection-change event,
which checks the number of rows in T.

I don't think you can prevent the adding of a row,
but you may delete the last row, immediately after
it was created.

' ---------------- NewMacros
Option Explicit
Dim oAppClass As New ThisApplication
Dim R As Long
Dim T As Table

Sub Macro1() ' Or autoexec, autonew or whatever
Set oAppClass.oApp = Word.Application
Set T = ActiveDocument.Tables(1)
R = T.Rows.Count
End Sub

Sub Test4()
If T.Rows.Count > R Then
T.Rows.Last.Delete
End If
End Sub

' ----------------------- ThisApplication

Option Explicit
Public WithEvents oApp As Word.Application

Private Sub oApp_WindowSelectionChange(ByVal Sel As Selection)
Test4 ' or the code of Test4
End Sub

A weird workaraound, sure.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top