Results 1 to 3 of 3
  1. #1
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Word Story Ranges (Word97SR2)

    From the VBA help files in Word97/SR2 for Story Ranges:

    "The Add method isn't available for the StoryRanges collection. The number of stories in the StoryRanges collection is finite."


    Do they really mean "finite", or do they mean "fixed"? Or do they mean "there is an established maximum number of ranges"?


    The two macros below establish a string of text composed of all the stories in a document.

    Without utilising a series of types as indexes (where index is a wdStoryType constant), there doesn't seem to be an easy way of obtaining all the text from a document in a (user-defined) meaningful sequence.


    For example, suppose I wanted to extract page headers and document text, re-extracting the header text whenever the header changed???



    <pre>Sub test()
    Dim rng As Range
    Dim strText As String
    For Each rng In ActiveDocument.StoryRanges
    strText = strText & rng.Text
    Next rng

    End Sub

    Sub test2()
    Dim myStoryRange
    Dim strText As String
    For Each myStoryRange In ActiveDocument.StoryRanges
    strText = strText & myStoryRange.Text
    Next myStoryRange
    End Sub

    </pre>


  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Word Story Ranges (Word97SR2)

    How about print to file using a text driver?

    But seriously, you need to check the header and footer story ranges section by section or you don't know what you're going to get, and you need to deal with the footnotes/endnotes in some other manner.

  3. #3
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word Story Ranges (Word97SR2)

    > check the header and footer story ranges section by section

    Correct. That is, there doesn't eem to be an easy way. There appears no Method of an Document to stream out all text as it would be visible on a printer.

    I like your suggestion of print-to-text; that would use Word's printer interpretation of the stream. Footnotes appearing where they should.

    Otherwise we are into a macro of some sorts, which probably means a GUI form with various options ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •