+ Reply to Thread
Results 1 to 5 of 5

Return paragraph number based on found text

  1. #1
    Registered User
    Join Date
    08-23-2019
    Location
    Boston, MA
    MS-Off Ver
    16
    Posts
    7

    Return paragraph number based on found text

    Hello,

    I'm trying to write a portion of code that will find specific text in a Word document and return the paragraph number(s), where the text occurs. I thought the code below would suffice, but the code "aRng.Paragraphs.Count" simply returns "1" each time "QUESTION" is found. Any advice would be greatly appreciated!

    Please Login or Register  to view this content.
    Thanks,
    Roy

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,703

    Re: Return paragraph number based on found text

    I have not taken the time to test this but try

    Please Login or Register  to view this content.
    I am not 100% sure the "find" location will be Selection, but I think so.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    08-23-2019
    Location
    Boston, MA
    MS-Off Ver
    16
    Posts
    7

    Re: Return paragraph number based on found text

    Thank you, "6StringJazzer." Unfortunately, that throws a "438" runtime error.

  4. #4
    Valued Forum Contributor Haluk's Avatar
    Join Date
    02-14-2019
    Location
    Turkiye
    MS-Off Ver
    2010 - 64 Bit on Windows-11 (22 H2) 64 Bit
    Posts
    1,147

    Re: Return paragraph number based on found text

    Try this;

    Please Login or Register  to view this content.
    .

  5. #5
    Registered User
    Join Date
    08-23-2019
    Location
    Boston, MA
    MS-Off Ver
    16
    Posts
    7

    Re: Return paragraph number based on found text

    Thanks, Haluk! That got it!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. how to structure formula to return an amt based on number and text
    By Iappreciate in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 05-24-2016, 09:51 AM
  2. Replies: 2
    Last Post: 09-12-2015, 11:02 AM
  3. Trying to Return a Number in a Cell based on Text
    By jslavinsky in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 07-01-2014, 11:23 PM
  4. Trying to Return a Number in a Cell based on Text
    By jslavinsky in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 07-01-2014, 03:17 PM
  5. [SOLVED] Return Column Number when specific text is found
    By Simon.xlsx in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-29-2014, 12:20 PM
  6. [SOLVED] If specific text is found in cell, then return a number
    By csch123 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-31-2013, 05:07 PM
  7. Replies: 8
    Last Post: 11-07-2008, 09:26 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1