J
JBNewsGroup
Hi,
I am working in WORD2000 VBA.
I need help and / or an explanation of the following Table procedure. I am
either doing something wrong or I am missing a point someplace. I have the
following procedure:
Private Sub DeleteTableRows (oTable As Table, _
RowsToDelete() as Integer, _
NoOfDeletes As Integer)
Dim oRow as Range
Dim J As Integer
Dim RowNo As Integer
Debug.Print "On Entry: " & oTable.Rows.Count
For J = NoOfDeletes To 1 Step -1
RowNo = RowsToDelete (J)
Set oRow = oTable.Rows (RowNo).Range
oRow.Delete
Next J
Debug.Print "On Exit: " & oTable.Rows.Count
End Sub
On entry to the procedure the first Debug.Print shows that I have a table of
50 rows. After executing 5 deletes the second Debug.Print shows that I
still have a table of 50 Rows instead of 45 rows. If I call the routine a
second time (ignoring the row count) only the row text is deleted for the
rows defined for the second call. The rows do not seem to be deleted as in
the first call. Note: prior to calling the procedure I execute "Set oTable
= ActiveDocument.Tables(TableNo)". I define oTable only once for all the
procedure calls.
Any help and explanation of what is occurring will be greatly appreciated.
Thanks in advance for any help.
Jerry Bodoff
I am working in WORD2000 VBA.
I need help and / or an explanation of the following Table procedure. I am
either doing something wrong or I am missing a point someplace. I have the
following procedure:
Private Sub DeleteTableRows (oTable As Table, _
RowsToDelete() as Integer, _
NoOfDeletes As Integer)
Dim oRow as Range
Dim J As Integer
Dim RowNo As Integer
Debug.Print "On Entry: " & oTable.Rows.Count
For J = NoOfDeletes To 1 Step -1
RowNo = RowsToDelete (J)
Set oRow = oTable.Rows (RowNo).Range
oRow.Delete
Next J
Debug.Print "On Exit: " & oTable.Rows.Count
End Sub
On entry to the procedure the first Debug.Print shows that I have a table of
50 rows. After executing 5 deletes the second Debug.Print shows that I
still have a table of 50 Rows instead of 45 rows. If I call the routine a
second time (ignoring the row count) only the row text is deleted for the
rows defined for the second call. The rows do not seem to be deleted as in
the first call. Note: prior to calling the procedure I execute "Set oTable
= ActiveDocument.Tables(TableNo)". I define oTable only once for all the
procedure calls.
Any help and explanation of what is occurring will be greatly appreciated.
Thanks in advance for any help.
Jerry Bodoff