+ Reply to Thread
Results 1 to 8 of 8

Extract sentences containing a keyword and output results to Excel

  1. #1
    Forum Contributor
    Join Date
    07-06-2009
    Location
    London, England
    MS-Off Ver
    Microsoft 365, Excel, Version 2402
    Posts
    184

    Extract sentences containing a keyword and output results to Excel

    Hello.
    I found the attached code on Microsoft Community by Graham Mayor which searches a Word document (I'm using Office 365) for a keyword and outputs the sentence to Excel. It works really well. I was wondering if someone could extend the code so that it also outputs the line number and page number too - this would be really helpful

    Thank you

    Please Login or Register  to view this content.

  2. #2
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Extract sentences containing a keyword and output results to Excel

    After:
    Please Login or Register  to view this content.
    Insert:
    Please Login or Register  to view this content.
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    Forum Contributor
    Join Date
    07-06-2009
    Location
    London, England
    MS-Off Ver
    Microsoft 365, Excel, Version 2402
    Posts
    184

    Re: Extract sentences containing a keyword and output results to Excel

    Thank you - this works.
    I had worked out from internet research that wdActiveEndPageNumber is used to capture page numbers but wasn't sure how to implement. Great job.

  4. #4
    Forum Contributor
    Join Date
    12-27-2021
    Location
    China
    MS-Off Ver
    Ms office 2019
    Posts
    188

    Re: Extract sentences containing a keyword and output results to Excel

    Hello, everyone. I accidentally browsed this webpage and found that this code is really practical.
    On this basis, I want to raise a demand. I wonder if anyone can answer it.
    According to the code of post # 1, you can only paste the code to the word document you want to find.
    Can you fix a blank word document to store the code, pop up the document selection box to select the file each time you execute the macro, and then other codes are the same?

  5. #5
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Extract sentences containing a keyword and output results to Excel

    Quote Originally Posted by 302 View Post
    According to the code of post # 1, you can only paste the code to the word document you want to find.
    The code can be stored in any document or template. The only proviso when running the code is that the document you want to process must be the active one (i.e. on-screen when you run the code).

  6. #6
    Forum Contributor
    Join Date
    12-27-2021
    Location
    China
    MS-Off Ver
    Ms office 2019
    Posts
    188
    can I use the pop up window select file ?

  7. #7
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Extract sentences containing a keyword and output results to Excel

    Not without rewriting parts of the code. For example, you might replace:
    Please Login or Register  to view this content.
    with:
    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    12-27-2021
    Location
    China
    MS-Off Ver
    Ms office 2019
    Posts
    188

    Re: Extract sentences containing a keyword and output results to Excel

    wow, you are great , thanks a lot.

+ 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. Excel. Extract word from sentences
    By erci74 in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 10-22-2022, 05:01 PM
  2. Extract words (out of a list) from sentences
    By Orphblk in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-10-2020, 08:56 PM
  3. Replies: 0
    Last Post: 09-07-2015, 04:05 PM
  4. Excel VBA to scan a PDF for keyword and extract PDF Pages to single PDF File
    By Brawnystaff in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-19-2014, 02:00 AM
  5. Find a requested word within sentences and output those sentences elsewhere
    By swfred2000 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-19-2014, 02:24 PM
  6. Keyword Searching in a Webpage and Tabulating the results in an Excel Sheet
    By veejar in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-01-2012, 11:56 PM
  7. How can I extract sentences from this website
    By DenniGa in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-27-2009, 04:29 PM

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