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!

--
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

Re: Delete Current Bookmark by Dave

Dave
Thu Apr 14 10:28:06 CDT 2005

Hi Bill,

You can use:

Selection.Bookmarks(1).Delete

HTH,
Dave

"Bill Foley" <wfoley1@EATSPAMANDDIEtxu.com> wrote in message
news:eM51rJQQFHA.2132@TK2MSFTNGP14.phx.gbl...
> 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!
>
> --
> 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
>
>



Re: Delete Current Bookmark by Bill

Bill
Thu Apr 14 11:23:03 CDT 2005

Sheesh, what a moron! And to think I almost got that round peg in that
square hole!

THANKS!

--
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" <dlett@NOsmconst.comSPAM.com> wrote in message
news:%23B9nxaQQFHA.128@tk2msftngp13.phx.gbl...
> Hi Bill,
>
> You can use:
>
> Selection.Bookmarks(1).Delete
>
> HTH,
> Dave
>
> "Bill Foley" <wfoley1@EATSPAMANDDIEtxu.com> wrote in message
> news:eM51rJQQFHA.2132@TK2MSFTNGP14.phx.gbl...
> > 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!
> >
> > --
> > 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
> >
> >
>
>