Delete a table between two bookmarks

S

SoNew2This

What I would like to do is delete a table between two bookmarks if row 2 cell
1 is blank. I've seen how to delete between two bookmarks:

Dim oRng As Range
With ActiveDocument
Set oRng=.Range(Start:=Bookmarks("BK1").Range.End,_
End:=BookMarks("BK2").Range.Start)
oRng.Delete
End With

But how would I test to see if the cell is blank and if so then delete the
table.

Thanks,
 
H

Helmut Weber

Hi,
Dim oRng As Range
With ActiveDocument
Set oRng=.Range(Start:=Bookmarks("BK1").Range.End,_
End:=BookMarks("BK2").Range.Start)
oRng.Delete
End With

like that:

Sub Test7()
Dim oRng As Range
With ActiveDocument
Set oRng = .Range(Start:=.Bookmarks("BK1").Range.End, _
End:=.Bookmarks("BK2").Range.Start)
If Len(oRng.Tables(1).Cell(2, 1).Range) = 2 Then
oRng.Tables(1).Delete
End If
End With
End Sub

Note that there is a period missing
before "bookmarks" in your code.

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 

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