How determine if data is entered into a table cell?

R

Robert Crandal

My Word document begins with a 20 by 6 table (i.e 20 rows x 6 columns).

When somebody inserts data into the BOTTOM-MOST RIGHT cell,
then enters data (or does not enter data), then presses the tab key, I would
like
to add a new row at the bottom of the table. Basically, if someone presses
the tab key while in the last row and last column of my table, I need to
generate
a new row.

How is this done?

Thanks!
 
T

That Guy

My Word document begins with a 20 by 6 table (i.e 20 rows x 6 columns).

When somebody inserts data into the BOTTOM-MOST RIGHT cell,
then enters data (or does not enter data), then presses the tab key, I would
like
to add a new row at the bottom of the table.  Basically, if someone presses
the tab key while in the last row and last column of my table, I need to
generate
a new row.

How is this done?

Thanks!

I am using word 2003 and this functionality is built right in. When I
hit tab at the end of a row I get a new row.
 
R

Robert Crandal

Oh you're right, I didn't realize that Word 2007 has the same feature.

Users were filling in the table, but they never pressed tab once they
reached the last row and last column, which means that a new row never
got generated.

When a Word document is first opened, is there a macro that can
automatically
create a new row only if the bottom row is filled up with data? I'm just
looking
for a way to help users by precreating an empty row if the table is full,
because
most of my users are not aware how to create new rows.

Thanks
 
J

jkorchok

Oh you're right, I didn't realize that Word 2007 has the same feature.

Users were filling in the table, but they never pressed tab once they
reached the last row and last column, which means that a new row never
got generated.

When a Word document is first opened, is there a macro that can
automatically
create a new row only if the bottom row is filled up with data?  I'm just
looking
for a way to help users by precreating an empty row if the table is full,
because
most of my users are not aware how to create new rows.

Thanks

I usually just place an a field in the bottom right cell with default
text that says "Tab to create new row". This can either be a MACRO
field with prompt text or a text from field with default text. When
users tab into that cell, the field is selected and easily deleted by
the user.

John Korchok
 
T

That Guy

You can easily make a macro in the documents open routine that will
create a new row if data is present in any specific cell in a table.

What you want to do is grab the range int he last cell and compare it
to the empty cell value. If the table cell has something in it then
tell the table to add a row.

Like this:

Private Sub Document_Open()
Dim strTemp As String
Dim intRowCount As Integer
Dim intColumnCount As Integer

intRowCount = ActiveDocument.Tables(1).Rows.Count
intColumnCount = ActiveDocument.Tables(1).Columns.Count

strTemp = ActiveDocument.Tables(1).Cell(intro,
intColumnCount).Range

If StrComp(strTemp, Chr(13) & Chr(7), vbTextCompare) <> 0 Then
ActiveDocument.Tables(1).Rows.Add
End If

End Sub

That should do the trick.
 
T

That Guy

You can easily make a macro in the documents open routine that will
create a new row if data is present in any specific cell in a table.

What you want to do is grab the range int he last cell and compare it
to the empty cell value. If the table cell has something in it then
tell the table to add a row.

Like this:

Private Sub Document_Open()
    Dim strTemp As String
    Dim intRowCount As Integer
    Dim intColumnCount As Integer

    intRowCount = ActiveDocument.Tables(1).Rows.Count
    intColumnCount = ActiveDocument.Tables(1).Columns.Count

    strTemp = ActiveDocument.Tables(1).Cell(intRowCount, intColumnCount).Range

    If StrComp(strTemp, Chr(13) & Chr(7), vbTextCompare) <> 0 Then
        ActiveDocument.Tables(1).Rows.Add
    End If

End Sub

That should do the trick.

I noticed a typo in the code.
 

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