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 / August 2005

Tip: Looking for answers? Try searching our database.

Delete text of bookmark?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ed - 03 Aug 2005 21:23 GMT
I can add text to a bookmark, but for some reason I can't delete it or
overwrite with "".    I'm using
   ActiveDocument.Bookmarks("LeftOffHere").Select
   ActiveDocument.Bookmarks("LeftOffHere").Range.Text = ""
   ActiveDocument.Bookmarks("LeftOffHere").Delete
The bookmark deletes, but the text is still there!  What am I doing wrong?
Ed
Jean-Guy Marcil - 03 Aug 2005 21:31 GMT
Ed was telling us:
Ed nous racontait que :

> I can add text to a bookmark, but for some reason I can't delete it or
> overwrite with "".    I'm using
[quoted text clipped - 3 lines]
> The bookmark deletes, but the text is still there!  What am I doing
> wrong? Ed

What else are you doing in your code? What Word version?

All you need is:
   ActiveDocument.Bookmarks("LeftOffHere").Range.Text = ""
this will delete the text in the bookmark, and the bookmark itself (once the
text is gone, what is there to bookmark? Nothing!).
You do not need to Select it first.

If it does not, tell us more about your particular situation because it
should.

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

Ed - 03 Aug 2005 21:55 GMT
Jean-Guy:
> What else are you doing in your code? What Word version?
>
[quoted text clipped - 6 lines]
> If it does not, tell us more about your particular situation because it
> should.

The book mark is to mark my place in a long document, so when I reopen the
doc I can go right to where I left off.  The full macro (see below) checks
to see if the bookmark exists: if yes, it selects the bookmark to take me to
that place, then deletes it; if no, it creates the bookmark and puts
highlighted text in it.  The bookmark deletes okay, but the text is still
there.  I'm using Word 2000.

Ed

Sub LeftOffHere()

If ActiveDocument.Bookmarks.Exists _
 ("LeftOffHere") = True Then
   ActiveDocument.Bookmarks("LeftOffHere").Select
   ActiveDocument.Bookmarks("LeftOffHere").Range.Text = ""
   ActiveDocument.Bookmarks("LeftOffHere").Delete
Else
   ActiveDocument.Bookmarks.Add Name:="LeftOffHere"
   ActiveDocument.Bookmarks("LeftOffHere").Range.HighlightColorIndex =
wdBrightGreen
   ActiveDocument.Bookmarks("LeftOffHere").Range.Text = "~~**HERE**~~"
End If

End Sub
Helmut Weber - 04 Aug 2005 12:32 GMT
Hi Ed,

there are two kinds of bookmarks,
lets call them exclusive and inclusive.

Exclusive bookmarks look like !bookmark.text.
Inclusive bookmarks look like [bookmark.text].

Both behave strangely, in a way.

You can assign text to an exclusive bookmark,
ActiveDocument.Bookmarks("Mark1").Range.Text = "xxxx"
however,
msgbox ActiveDocument.Bookmarks("Mark1").Range.Text
returns nothing.

You can assign text to an inclusive bookmark, too,
ActiveDocument.Bookmarks("Mark2").Range.Text = "xxxxx"
however, after that, the bookmark doesn't exist anymore.

There are numerous examples here how to overcome that.

Need more help?

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
Ed - 04 Aug 2005 14:41 GMT
Thanks for the info, Helmut.  It appears I need to dig a bit deeper into
bookmarks.  If I run into trouble, I'll yell!
Ed

> Hi Ed,
>
[quoted text clipped - 26 lines]
> Win XP, Office 2003
> "red.sys" & Chr$(64) & "t-online.de"
 
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.