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

Tip: Looking for answers? Try searching our database.

Delete Current Bookmark

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bill Foley - 14 Apr 2005 15:58 GMT
Hey Gang, back with another question:

Word XP

I have a bookmarked document that I am trying to manipulate various
bookmarks to create subdocuments.  I have code that bookmarks selected
paragraphs with incremented bookmark names, and it works fine.

I also have code that goes through and deletes all bookmarks in the
document, if needed.

What I can't seem to get is to delete the current bookmark.  For example, if
a user selects text and assigns a bookmark to it (bma_8, for example).  I
know they can select the text, click "Insert", "Bookmarks", click the
"Delete" button and that bookmark is deleted.  I also know that you can
select a bookmarked set of text and assign a different bookmark to it
(bmb_5, for example).  But I am trying to create a macro that does the
following (after a selection of bookmarked text has been made):

- Determine the bookmark name, then delete that bookmark (not the text, just
the bookmark itself).

Using the recorder, simply includes the bookmark name of the selected text.
I want it to be variable so whatever bookmark is selected, it can be
deleted.

The concept of the code I need (which I obviously can't get to work) is
below:

========

Sub DeleteCurrentBookmark()

Dim Mybm As Bookmark

With Selection.Bookmarks
  If .Count = 1 Then
     Set Mybm = .Item(1).Name
   ActiveDocument.Bookmarks(Mybm).Delete
  End If
End With

End Sub

========

TIA!

Signature

Bill Foley, Microsoft MVP (PowerPoint)
Microsoft Office Specialist Master Instructor - XP
www.pttinc.com
Check out PPT FAQs at: http://www.rdpslides.com/pptfaq/
Check out Word FAQs at: http://word.mvps.org/FAQs/General/index.htm

Dave Lett - 14 Apr 2005 16:28 GMT
Hi Bill,

You can use:

Selection.Bookmarks(1).Delete

HTH,
Dave

> Hey Gang, back with another question:
>
[quoted text clipped - 43 lines]
>
> TIA!
Bill Foley - 14 Apr 2005 17:23 GMT
Sheesh, what a moron!  And to think I almost got that round peg in that
square hole!

THANKS!

Signature

Bill Foley, Microsoft MVP (PowerPoint)
Microsoft Office Specialist Master Instructor - XP
www.pttinc.com
Check out PPT FAQs at: http://www.rdpslides.com/pptfaq/
Check out Word FAQs at: http://word.mvps.org/FAQs/General/index.htm

> Hi Bill,
>
[quoted text clipped - 55 lines]
> >
> > TIA!
 
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.