I would like to delete all the bookmarks that start with the prefix
"Diss_Chapter". The other ones I would like to leave alone. How can
this be achieved using Word VBA?

Help is appreciated. Thank you very much in advance.

Regards,

Andreas

Re: Delete only certain bookmarks (starting with Prefix "Diss_Chapter") by Jean-Guy

Jean-Guy
Wed Feb 14 10:13:05 CST 2007

andreas was telling us:
andreas nous racontait que :

> I would like to delete all the bookmarks that start with the prefix
> "Diss_Chapter". The other ones I would like to leave alone. How can
> this be achieved using Word VBA?
>
> Help is appreciated. Thank you very much in advance.
>
> Regards,
>
> Andreas

Try this:

'_______________________________________
Const strBookPrefix As String = "Diss_Chapter"
Dim i As Long

With ActiveDocument.Bookmarks
For i = .Count To 1 Step -1
If Left(.Item(i).Name, 12) = strBookPrefix Then
.Item(i).Delete
End If
Next
End With
'_______________________________________

But if you meant that you not only wanted to delete the bookmarks, but the
text as well, replace

.Item(i).Delete

by

.Item(i).Range.Delete

--

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



Re: Delete only certain bookmarks (starting with Prefix "Diss_Chapter") by Helmut

Helmut
Wed Feb 14 10:16:57 CST 2007

Hi Andreas,

like this:

Sub Test99992()
Dim oDcm As Document
Dim oBkm As Bookmark
Set oDcm = ActiveDocument
For Each oBkm In oDcm.Bookmarks
If Left(oBkm.Name, 12) = "Diss_Chapter" Then
oBkm.Delete
End If
Next
End Sub

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

Re: Delete only certain bookmarks (starting with Prefix "Diss_Chapter") by andreas

andreas
Thu Feb 15 12:21:30 CST 2007

On 14 Feb., 17:13, "Jean-Guy Marcil" <DontEvenTry@NoSpam> wrote:
> andreas was telling us:
> andreas nous racontait que :
>
> > I would like to delete all the bookmarks that start with the prefix
> > "Diss_Chapter". The other ones I would like to leave alone. How can
> > this be achieved using Word VBA?
>
> > Help is appreciated. Thank you very much in advance.
>
> > Regards,
>
> > Andreas
>
> Try this:
>
> '_______________________________________
> Const strBookPrefix As String = "Diss_Chapter"
> Dim i As Long
>
> With ActiveDocument.Bookmarks
> For i = .Count To 1 Step -1
> If Left(.Item(i).Name, 12) = strBookPrefix Then
> .Item(i).Delete
> End If
> Next
> End With
> '_______________________________________
>
> But if you meant that you not only wanted to delete the bookmarks, but the
> text as well, replace
>
> .Item(i).Delete
>
> by
>
> .Item(i).Range.Delete
>
> --
>
> Salut!
> _______________________________________
> Jean-Guy Marcil - Word MVP
> jmarcilREM...@CAPSsympatico.caTHISTOO
> Word MVP site:http://www.word.mvps.org

Jean-Guy,
nice code. It is working fine. Thank you!


Re: Delete only certain bookmarks (starting with Prefix "Diss_Chapter") by andreas

andreas
Thu Feb 15 12:24:02 CST 2007

On 14 Feb., 17:16, Helmut Weber <nbhymsjxd...@mailinator.com> wrote:
> Hi Andreas,
>
> like this:
>
> Sub Test99992()
> Dim oDcm As Document
> Dim oBkm As Bookmark
> Set oDcm = ActiveDocument
> For Each oBkm In oDcm.Bookmarks
> If Left(oBkm.Name, 12) = "Diss_Chapter" Then
> oBkm.Delete
> End If
> Next
> End Sub
>
> --
> Greetings from Bavaria, Germany
>
> Helmut Weber, MVP WordVBA
>
> Win XP, Office 2003
> "red.sys" & Chr$(64) & "t-online.de"


Helmut,

it is working fine. Thank you. I am not quite sure about the handling
of right answers. Is it sufficent to just rate the answers by clicking
these stars or do you experts need always a written feedback by mail
even if the user is satisfied with your answer.


Re: Delete only certain bookmarks (starting with Prefix "Diss_Chapter") by Helmut

Helmut
Fri Feb 16 03:01:43 CST 2007

"Thank you" is quite sufficient and welcome, too.

Ratings are not shown in all newsreaders.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"