Results 1 to 3 of 3

Thread: [RESOLVED] Word Selecting text under a heading

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2005
    Posts
    7

    Resolved [RESOLVED] Word Selecting text under a heading

    All i'm asking is for a push in the right direction here.

    In this document, the headings and text are all a specific style. How might i select a range of text/tables from 1 heading to the line just b4 the next heading? It would be nice if i could go through line by line and check if the text is a certain style (ie a heading) then record that position. Once i have the positions i'm in easy street!

    VB Code:
    1. r = d.Range(Start:=startPos, End:=endPos)

    I will be needing to iterate through all the headings in the document which isn't that hard conceptially, I'm just lost in the amount of methods and properties the document object has

    Much Love!

  2. #2
    Superbly Moderated NeedSomeAnswers's Avatar
    Join Date
    Jun 2002
    Location
    Manchester uk
    Posts
    2,657

    Re: Word Selecting text under a heading

    Hi there,

    not sure about being able to pick specific places in a document to search between (unless you place bookmarks in the document maybe in the Heading lines), but maybe i can help you a bit.

    The following code shows how to loop through & record the styles for Paragraphs, Words & Tables.

    They where the only collections i could think of that might be of some use to you, there isn't one for lines that i can find anyway.

    VB Code:
    1. Sub test()
    2.  
    3.  
    4. Dim n As Integer
    5. Dim strParagraphStyle() As String
    6. Dim strWordsStyle() As String
    7. Dim strTablesStyle() As String
    8.  
    9. For n = 1 To ActiveDocument.Paragraphs.Count
    10.     ReDim strParagraphStyle(n)
    11.     strParagraphStyle(n) = ActiveDocument.Paragraphs.Item(n).Style
    12. Next
    13.  
    14. For n = 1 To ActiveDocument.Words.Count
    15.     ReDim strWordsStyle(n)
    16.     strWordsStyle(n) = ActiveDocument.Words.Item(n).Style
    17. Next
    18.  
    19. For n = 1 To ActiveDocument.Tables.Count
    20.     ReDim strTablesStyle(n)
    21.     strTablesStyle(n) = ActiveDocument.Tables.Item(n).Style
    22. Next
    23.  
    24. End Sub

    hope it's of some use !

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2005
    Posts
    7

    Re: Word Selecting text under a heading

    Thanks a heap!

    - Much Love

Posting Permissions

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



Click Here to Expand Forum to Full Width