PDA

View Full Version : Solved: Deleting table rows using bookmarks



stecstec
06-27-2006, 06:32 AM
Hope this is a quick one!

I'm trying to delete 3 rows in a table, using a bookmark preferably. Can anyone help with the code on this?

cheers, Steve.

fumei
06-27-2006, 09:41 AM
Bookmarks can be deleted with .Delete. So use .Delete. What is the problem?

ActiveDocument.Bookmarks(ThisOne").Deletewill delete the bookmark "ThisOne".

Rows in a table are deleted with .Delete.ActiveDocument.Tables(1).Rows(3).Deletewill delete the 3rd row of Table 1.

Perhaps if you:

1. describe exactly what you are doing;
2. post some code of what you are doing.

we may be able to suggest something. I suspect what you really want to do is delete the Range...but...maybe not. Post more details.

fumei
06-27-2006, 09:57 PM
Just following through...

Say you have properly bookmarked the 3rd, 4th, 5th rows of Table 4. The bookmark is named OuttaHere.

ActiveDocument.Bookmarks("outtahere").Range.Deletewill delete the contents, but not the bookmark itself.

ActiveDocument.Bookmarks("outtahere").Deletewill delete the bookmarks, but not the contents.

It is not clear what you want to do exactly. Do you want to actually delete the rows themselves? Because if it is the rows themselves, then using bookmarks will not do the trick. Rows are not part of the bookmarks collection. They belong to the Table.

stecstec
06-28-2006, 12:55 AM
Cheers for replying Gerry,

I was trying to use a bookmark to reference a cell in a table, but as you suggest it would be better to simply to reference the table instead.

Thanks for your help - much appreciated!

Steve.