Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2008

Tip: Looking for answers? Try searching our database.

Delete a table between two bookmarks

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
SoNew2This - 14 Mar 2008 18:33 GMT
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,
Helmut Weber - 14 Mar 2008 23:01 GMT
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

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.