Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Delete text in bookmark

1,492 views
Skip to first unread message

Allan Wong

unread,
Oct 31, 2001, 1:39:23 AM10/31/01
to
Hi, how can I delete text in bookmark from VBA?

The below doesn't work.

ActiveDocument.Bookmarks("Comments").Range.Text = ""
ActiveDocument.Bookmarks("Comments").Range.Delete
ActiveDocument.Bookmarks("Comments").Range.Cut


Allan Wong

ibby

unread,
Oct 31, 2001, 4:42:44 AM10/31/01
to
Hi Allan,

For the above to work, the text needs to be enclosed by the bookmark - take
a look at the following article:

http://www.mvps.org/word/FAQs/MacrosVBA/WorkWithBookmarks.htm


--
Hope this helps.
ibby

Please post replies or follow-ups to the **newsgroup** so that participants
may benefit or contribute.

Martin Sägesser

unread,
Nov 5, 2001, 9:03:49 AM11/5/01
to
Hi Allan
when the Text is inside the bookmark,
ActiveDocument.Bookmarks("Test").Range = ""
should work.

When you insert text into a bookmark, the bookmark does not contain the
text, you have to redefine the bookmark:

Sub test()
Dim rng As Range
Dim sText As String

sText = "abc"
Set rng = ActiveDocument.Bookmarks("Test").Range
rng = sText
ActiveDocument.Bookmarks.Add ("Test"), rng

End Sub

Now you can change the text by changing sText.

hth, Martin

In article <#V7idZdYBHA.2020@tkmsftngp07>, bu...@singnet.com.sg says...

Allan Wong

unread,
Nov 7, 2001, 11:57:16 AM11/7/01
to
It works! Thanks.

Regards,
Allan


"Allan Wong" <bu...@singnet.com.sg> wrote in message
news:#V7idZdYBHA.2020@tkmsftngp07...

0 new messages