+ Reply to Thread
Results 1 to 8 of 8

Extract Certain Text from Word into Excel Using VBA

  1. #1
    Registered User
    Join Date
    05-18-2018
    Location
    United States of America
    MS-Off Ver
    2007
    Posts
    2

    Extract Certain Text from Word into Excel Using VBA

    Hi,
    i'm new to VBA and i'm learning now.
    My requirement is to match the word PROC or PRIC from a word document and move the next strings to excel under corresponding headers.
    for (e.g) my word document (sample.docx) contains
    PROC-1801
    PROC-1901
    PRIC-1801
    PRIC-1901

    my excel (sample.xlsm) contains the heading
    PROC PRIC

    code need to check the word PROC and move the text 1801, 1901 to excel under the heading PROC like below
    PROC
    1801
    1901

    Have gone through some of the online site and come up with the below code. this code doesn't give any error but the results were not coming in sample1 spreadsheet.

    Code is given below:

    Please Login or Register  to view this content.
    Last edited by FDibbins; 05-20-2018 at 11:09 PM.

  2. #2
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Cool Re: Extract Certain Text from Word into Excel Using VBA

    try to use [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

  3. #3
    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 Certain Text from Word into Excel Using VBA

    It's impossible to tell for sure what's going on from your code, because you're using Selections & Moves in Word. Furthermore, having lines like:
    Tble1 = 5
    followed by:
    If Tble1 = 0 Then
    and:
    Tble1 = 2
    followed by:
    If Tble1 = 0 Then
    are pointless, since the If tests must always return False. Try something along the lines of the code below:
    Please Login or Register  to view this content.
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  4. #4
    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 Certain Text from Word into Excel Using VBA

    Cross-posted at: http://www.vbaexpress.com/forum/show...xcel-Using-VBA
    Please read Excel Forum's Cross-Posting policy in rule 8: http://www.excelforum.com/forum-rule...rum-rules.html

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Extract Certain Text from Word into Excel Using VBA

    Admin note: I have tried to add tags to post #1, but the text disappears on edit
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  6. #6
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Extract Certain Text from Word into Excel Using VBA

    Hi Ford,
    Copy whole text from post, edit post, paste text from the clipboard, add tags

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Extract Certain Text from Word into Excel Using VBA

    Quote Originally Posted by sandy666 View Post
    Hi Ford,
    Copy whole text from post, edit post, paste text from the clipboard, add tags
    I thought about doing that, but figured if members saw that an admin or mod had tried, it would be OK - I have added the tags

  8. #8
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Extract Certain Text from Word into Excel Using VBA

    Quote Originally Posted by FDibbins View Post
    I thought about doing that, but figured if members saw that an admin or mod had tried, it would be OK - I have added the tags
    I did it a few times and it works. Happy tagging

+ 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. Extract Word header table data to excel (closed word document)
    By Yakov on Excel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-14-2017, 02:12 PM
  2. [SOLVED] Extract data right of certain word in text
    By ScabbyDog in forum Excel General
    Replies: 2
    Last Post: 04-11-2013, 07:06 AM
  3. [SOLVED] Extract word from text
    By Aland2929 in forum Excel General
    Replies: 7
    Last Post: 05-09-2012, 06:41 AM
  4. [SOLVED] extract text after a certain word
    By marreco in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-11-2012, 07:10 AM
  5. Excel 2007 : Extract Data from Word/text
    By maverick09 in forum Excel General
    Replies: 2
    Last Post: 12-08-2011, 01:00 PM
  6. Extract text after a specified word
    By tahirfayyaz in forum Excel General
    Replies: 2
    Last Post: 01-24-2010, 04:54 PM
  7. Extract a text from word and place it en excel or word?
    By Elegidos in forum Word Programming / VBA / Macros
    Replies: 1
    Last Post: 12-09-2009, 06:14 AM

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