Bottleneck in BookmarkLines

  • When I call the BookmarkLines procedure on a very large document, this procedure takes a lot of time to execute and result in very slow responses.

    I have included the source code of this procedure. Is there any way I can speed up this procedure?

  • I must say that I use this procedure in a loop that allows me to get the Start and End line of each bookmark in a document. If there are 200 bookmarks (which is not uncommon in my application), this procedure is called 200 times.

    If I'm right, this procedure searches each bookmark from the start. Maybe I could get rid of this if I knew how to get the start and end lines from all bookmarks without having to search the document for every bookmark but by browsing through the bookmarks themselves.

    Is this possible? If yes, can someone tell me how I can achieve this?