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!