R
Rob
Hi,
I have a Word document which has text, as well as many tables in it.
One cell of the tables may contain a text string (eg "foo bar"). I am
trying to write a macro which will delete the entire row in which this
occurs in the table.
Since I have hundreds of tables, I would like this to be automated. I
was doing a Ctrl-F & searching for the string, then if I found it I
was manually deleting the row. This way obviously sucks.
From searching on the site, I found a similar thread & tried copying
the code from it. The code I have tried is:
Public Sub Delete_Row()
Dim oTable As Table
Dim oRow As Row
With oTable
For Each oRow In .Rows
If oRow.Cells(1).Range.Text = "Foo Bar" Then
oRow.Delete
End If
Next oRow
End With
End Sub
***********************
I am getting the following error: Run-Time Error '91': Object
Variable or With Block Variable Not Set.
What is wrong here?
Thanks in advance,
Rob
I have a Word document which has text, as well as many tables in it.
One cell of the tables may contain a text string (eg "foo bar"). I am
trying to write a macro which will delete the entire row in which this
occurs in the table.
Since I have hundreds of tables, I would like this to be automated. I
was doing a Ctrl-F & searching for the string, then if I found it I
was manually deleting the row. This way obviously sucks.
From searching on the site, I found a similar thread & tried copying
the code from it. The code I have tried is:
Public Sub Delete_Row()
Dim oTable As Table
Dim oRow As Row
With oTable
For Each oRow In .Rows
If oRow.Cells(1).Range.Text = "Foo Bar" Then
oRow.Delete
End If
Next oRow
End With
End Sub
***********************
I am getting the following error: Run-Time Error '91': Object
Variable or With Block Variable Not Set.
What is wrong here?
Thanks in advance,
Rob