locked
Efficient line walking RRS feed

  • Question

  • Hi,

    I need to implement efficient "line-walking" within word.

    Walking efficiently by paragraphs took a while to get right, but I was able to: after a few trials, I found out that the best way was to use Range.Next() with args (wdParagraph, 1), and use the returned range.

    Using the story range's paragraphs was really slow, where it seems every direct item access involved completely walking the range for every call. But Range.Next(wdParagraph) fixed. it.

    But no, for actual "visual" lines, this doesn't work. I'm using Range.Goto(wdGoToLine, wdGotoRelative, 1), but it's still very slow. Range.Next() ain't usable for lines.

    Any suggestions for a fast way to walk all lines in a document?

    BTW, the goal is the underlying layer on top of which to iimplement my vi/vim emulator. It's already working, but it's pretty slow.

    Thanks and best regards,

      - Jon
    ----------------------------------------------------
    ViEmu - vi/vim emulation for Visual Studio

    Wednesday, November 29, 2006 5:40 AM

Answers

  • Hi Jon

    the best place to have a discussion about optimizing Word's object model is the word.vba.general newsgroup. that's where you'll find the people who specialize in Word and have the greatest total experience. This forum is for questions concerning the VSTO technology.

    FWIW, since a line isn't a true object in the Word OM, your options are very limited...

    Wednesday, November 29, 2006 7:54 AM

All replies

  • Hi Jon

    the best place to have a discussion about optimizing Word's object model is the word.vba.general newsgroup. that's where you'll find the people who specialize in Word and have the greatest total experience. This forum is for questions concerning the VSTO technology.

    FWIW, since a line isn't a true object in the Word OM, your options are very limited...

    Wednesday, November 29, 2006 7:54 AM
  • Cindy, thanks a lot for your pointer. I will try to get it solved there. I'll also post the answer or a link to it if I end up finding one, for the benefit of whoever stumbles upon this in the future.

    Best regards,

      - Jon
    ----------------------------------------------------
    ViEmu - vi/vim emulation for Visual Studio
    Saturday, December 9, 2006 2:26 AM