Deleting table rows in a protected document

S

Steve

I have been researching all over the internet ever since I
discovered Word was capable of so much more (and yes, it's
cozy living under a rock).

I've been trying to find a way to delete rows of a table
where the second cell in the row is a blank field. I need
to keep the form protected so no one changes the
structure, so I put in form fields. But I also need to
get rid of extra lines in the table without unprotecting
the document?

Any ideas? I've figured out how to delete rows that
contain a text string in the first column, but after that
I'm stumped.
 
D

Doug Robbins - Word MVP

Hi Steve,

Use:

Dim myrange As Range, i As Integer
For i = ActiveDocument.Tables(1).Rows.Count To 1 Step -1
Set myrange = ActiveDocument.Tables(1).Cell(i, 2).Range
If Len(Trim(myrange)) = 2 Then
ActiveDocument.Tables(1).Rows(i).Delete
End If
Next i

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 

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