Results 1 to 11 of 11
  1. #1
    Star Lounger
    Join Date
    Dec 2002
    Location
    San Francisco, California, USA
    Posts
    54
    Thanks
    6
    Thanked 1 Time in 1 Post

    Outline Scheme Used In A Document (VBA/Word 97)

    I am interested in creating a string array that contains all outline numbering used in a document. That is, Article I in one cell of the array, Article II in another cell, Section 5.03(iv) in another, etc. The array once filled should contain all numbering used in the document. If possible, I'd also like to include the first sentence that follows the paragraph number (i.e., Section 5.03. Definitions.) in another column of the array.

    Any suggestions?

    Thank you.

  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: Outline Scheme Used In A Document (VBA/Word 97)

    Does the numbering coincide with paragraph styles (e.g., Heading1, Heading2)? If so, the laziest way ( <img src=/S/grin.gif border=0 alt=grin width=15 height=15> ) would be to create a Table of Contents, unlink it so it becomes plain text, parse that, and delete it. If not, and you need to sniff each paragraph to see what it's numbering is, I think it's a bit tricky (Word's numbering seems somewhat difficult to decipher with VBA).

  3. #3
    Star Lounger
    Join Date
    Dec 2002
    Location
    San Francisco, California, USA
    Posts
    54
    Thanks
    6
    Thanked 1 Time in 1 Post

    Re: Outline Scheme Used In A Document (VBA/Word 97)

    Yes, the numbering does coincide with the styles. You're thinking about the solution the same way I am. How do you limit the TOC to only bring in the first sentence for paragraphs that contain multiple sentences of text without marking the paragraphs? Also, how do you unlink the TOC after generation -- change the TOC styles to Normal and then reset characters (Ctrl+spacebar)?

    Thanks for your reply.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Outline Scheme Used In A Document (VBA/Word 97)

    You can unlink a field by selecting it and pressing Ctrl+Shift+F9. This will convert it to text. I don't know the answer to your other question.

  5. #5
    Star Lounger
    Join Date
    Dec 2002
    Location
    San Francisco, California, USA
    Posts
    54
    Thanks
    6
    Thanked 1 Time in 1 Post

    Re: Outline Scheme Used In A Document (VBA/Word 97)

    Hans,

    Thanks for your help.

    Larry

  6. #6
    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: Outline Scheme Used In A Document (VBA/Word 97)

    Word has certain criteria for determining what constitutes a "sentence." If these criteria work for you, imaging walking through the TOC the way you would do it interactively:
    [list=1]<LI>Position insertion point at the beginning of a TOC entry. Typically this would mean the beginning of the next paragraph (Ctrl+DownArrow). In VBA, that's:
    <pre>Selection.MoveDown unit:=wdParagraph, Count:=1, Extend:=wdMove</pre>

    <LI>Select to the end of the paragraph number. How will you recognize this? That depends on the numbering scheme you've chosen. If you're interested in help with that part, you'll need to give more information.

  7. #7
    Star Lounger
    Join Date
    Dec 2002
    Location
    San Francisco, California, USA
    Posts
    54
    Thanks
    6
    Thanked 1 Time in 1 Post

    Re: Outline Scheme Used In A Document (VBA/Word 97)

    Yes, it does help. I was thinking more in terms of evaluating ranges and styles because that is required to determine how to handle the text for each level. Let me explain. TOC 1 will generally looks like, Article I or Article II and then text will follow. I need to first parse Article I and then the rest of the text for the paragraph. Level 2 is a little more tricky. TOC 2 will contain Section 1.01. or Section 1.01, Section 1.1, etc., then the first sentence that follows (if there is a first sentence) needs to be caught as the section heading. So, for example, level two might contain Section 1.01. Definitions. Text text text text. So, I need to capture Section 1.01 in one cell and then Definitions or Accounting Terms and Determinations or whatever, in the adjacent array cell. Now, the following levels can be (a), or (i) or A. or whatever. Generally, the text that follows on these levels is irrelevant but sometimes, it's not. For example, you might have: (a) Receipt of Documents. Text text text. In this case you want to capture Receipt of Documents as the title for this subheading. On all levels you want an accumulated reference. So, for (a) above, you want the reference to say, Section 1.01(a) not just (a) because their may be other (a)s in your document.

    Does that help to explain the problem more thoroughly?

    Thanks for you help.

    Larry

  8. #8
    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: Outline Scheme Used In A Document (VBA/Word 97)

    I think you'll have to experiment a bit. If I recall correctly, there is a switch for the REF field that reconstructs the entire numbering chain for the paragraph it is in. Maybe you can use that somehow. If not, you'll have to keep track "manually." No more VBA today... off to see the Matrix Reloaded.

  9. #9
    Star Lounger
    Join Date
    Dec 2002
    Location
    San Francisco, California, USA
    Posts
    54
    Thanks
    6
    Thanked 1 Time in 1 Post

    Re: Outline Scheme Used In A Document (VBA/Word 97)

    Again, thanks for your help. I'll take a look at the REF field.

    Larry

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Outline Scheme Used In A Document (VBA/Word 97)

    The online help has an overview of all switches for the REF field. w is the one to refer to the full numbering (at least, it is in Word 2002; it was probably the same in Word 97.)

  11. #11
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Outline Scheme Used In A Document (VBA/Word 97)

    Here's an alternative to the TOC for getting the paragraph autonumber as a string:

    <pre>Sub GetAutoNumbersAsText()

    Dim aPara As Paragraph
    Dim strList As String

    For Each aPara In ActiveDocument.Paragraphs

    strList = aPara.Range.ListFormat.ListString
    MsgBox strList

    Next 'aPara
    End Sub
    </pre>

    Note that this will return the autonumber that is generated at the start of each paragraph via Numbering or Outline Numbering (and if the paragraph is not numbered, it will return an empty string). If you have additional numbering in the paragraph that is generated by say a ListNum field, not sure how you return this.

    Also, you'd still need to work out, per Jefferson's suggestions, where the first sentence ended.

    Gary

Posting Permissions

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