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 all bookmarks in file

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tony Logan - 22 Feb 2005 18:59 GMT
Can a macro delete all bookmarks in a file? I want to be able to delete all
of them without knowing in advance how many there are, since the number will
vary from file to file.

I'm using Word XP.
Jonathan West - 22 Feb 2005 19:06 GMT
> Can a macro delete all bookmarks in a file? I want to be able to delete
> all
[quoted text clipped - 3 lines]
>
> I'm using Word XP.

This will do the needful

Dim n as Long
For n = 1 to ActiveDocument.Bookmarks.Count
   ActiveDocument.Bookmarks(1).Delete
Next n

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup

Vince - 23 Feb 2005 01:00 GMT
Ha ha! Typo!

Dim n as Long
For n = 1 to ActiveDocument.Bookmarks.Count
    ActiveDocument.Bookmarks(n).Delete
Next n

> > Can a macro delete all bookmarks in a file? I want to be able to delete
> > all
[quoted text clipped - 10 lines]
>     ActiveDocument.Bookmarks(1).Delete
> Next n
Jonathan West - 23 Feb 2005 01:30 GMT
> Ha ha! Typo!
>
> Dim n as Long
> For n = 1 to ActiveDocument.Bookmarks.Count
>     ActiveDocument.Bookmarks(n).Delete
> Next n

No typo. You try it my way and then your way, and see which works.

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup

Vince - 23 Feb 2005 02:43 GMT
Oops! I take that back. Sorry!

> > Ha ha! Typo!
> >
[quoted text clipped - 4 lines]
>
> No typo. You try it my way and then your way, and see which works.
Jezebel - 23 Feb 2005 01:43 GMT
Vince, you should have tried it first, before proving so gleeefully to the
world that you're an obnoxious fuckwit.

> Ha ha! Typo!
>
[quoted text clipped - 17 lines]
>>     ActiveDocument.Bookmarks(1).Delete
>> Next n
Jonas - 15 Apr 2005 20:31 GMT
when I use this method for deleting all bookmarks, for some reason the var n
only goes up to half of the ActiveDocument.Bookmarks.Count total and then
exits the loop.  If I try to force the loop to calculate over half, it shows
the Bookmarks(n) to be invalid.  anybody have any clues?

Thanks alot,
J.

> Ha ha! Typo!
>
[quoted text clipped - 17 lines]
> >     ActiveDocument.Bookmarks(1).Delete
> > Next n
Greg Maxey - 15 Apr 2005 20:59 GMT
Jonas,

Try this:

Sub DeleteBookmarks()
Dim n As Long
For n = ActiveDocument.Bookmarks.Count To 1 Step -1
  ActiveDocument.Bookmarks(n).Delete
Next n

End Sub

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> when I use this method for deleting all bookmarks, for some reason
> the var n only goes up to half of the ActiveDocument.Bookmarks.Count
[quoted text clipped - 32 lines]
>>> www.intelligentdocuments.co.uk
>>> Please reply to the newsgroup
Jonas - 15 Apr 2005 22:02 GMT
Thanks for your reply.  

But I dont think this is going to work for me because Im controlling Word
from a non-microsoft language through com-handles.

> Jonas,
>
[quoted text clipped - 44 lines]
> >>> www.intelligentdocuments.co.uk
> >>> Please reply to the newsgroup
Vince - 16 Apr 2005 05:35 GMT
Should be (1).Delete and NOT (n).Delete. I thought it was a typo back then
until Jonathan corrected me.

****************************************
Dim n as Long
 For n = 1 to ActiveDocument.Bookmarks.Count
     ActiveDocument.Bookmarks(1).Delete
 Next n
****************************************

> when I use this method for deleting all bookmarks, for some reason the var n
> only goes up to half of the ActiveDocument.Bookmarks.Count total and then
[quoted text clipped - 25 lines]
> > >     ActiveDocument.Bookmarks(1).Delete
> > > Next n
 
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.