M
mikenam
I get a random Run-time error '5825' Object has been deleted
there are 5 tables all with 4 columns. The program runs through each
table and deletes all columns that have List or Adjust as a header. I
test with the same tables each time but i get error at different tables
each time. Running the program with 1 table is fine but multiple tables
the error pops up.
This line is the line that i get the error. Seems like it can't find
the table after it edits it correctly.
MsgBox IsObjectValid(oTb)
f = oTb.Columns.count
For Each oTb In ActiveDocument.Tables
tbl = tbl + 1
'if there are 4 columns then format the table
If oTb.Columns.count = 4 Then
i = 1
f = oTb.Columns.count
Do
test = Left(oTb.Cell(1, i).Range.Text, 4)
If test = "List" Or test = "Adju" Then
oTb.Columns(i).Delete
i = i
Else
i = i + 1
End If
MsgBox IsObjectValid(oTb)
f = oTb.Columns.count
Loop Until i > f
End If
there are 5 tables all with 4 columns. The program runs through each
table and deletes all columns that have List or Adjust as a header. I
test with the same tables each time but i get error at different tables
each time. Running the program with 1 table is fine but multiple tables
the error pops up.
This line is the line that i get the error. Seems like it can't find
the table after it edits it correctly.
MsgBox IsObjectValid(oTb)
f = oTb.Columns.count
For Each oTb In ActiveDocument.Tables
tbl = tbl + 1
'if there are 4 columns then format the table
If oTb.Columns.count = 4 Then
i = 1
f = oTb.Columns.count
Do
test = Left(oTb.Cell(1, i).Range.Text, 4)
If test = "List" Or test = "Adju" Then
oTb.Columns(i).Delete
i = i
Else
i = i + 1
End If
MsgBox IsObjectValid(oTb)
f = oTb.Columns.count
Loop Until i > f
End If