+ Reply to Thread
Results 1 to 10 of 10

Need to create a Excel Macro to import text from Word to Excel

  1. #1
    Forum Contributor
    Join Date
    11-29-2012
    Location
    Coimbatore, India
    MS-Off Ver
    Excel 2010
    Posts
    101

    Need to create a Excel Macro to import text from Word to Excel

    Hi Everyone,

    I need your help in creating a macro that should copy a text from word document and paste that into excel document.

    I'm attaching a word and excel document. If you see the word document, there will be a table. If the content of the second column is "Casual Visit" then it should take its corresponding value (i.e $15) and paste that into the excel document (in the cell I2). Is it possible to handle this. Please help me as i'm very new to macro. Thanks in advacne
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    11-29-2012
    Location
    Coimbatore, India
    MS-Off Ver
    Excel 2010
    Posts
    101

    Re: Need to create a Excel Macro to import text from Word to Excel

    Can someone please help me?

  3. #3
    Forum Contributor
    Join Date
    11-29-2012
    Location
    Coimbatore, India
    MS-Off Ver
    Excel 2010
    Posts
    101

    Re: Need to create a Excel Macro to import text from Word to Excel

    I got this code from internet.

    Please Login or Register  to view this content.
    I'm getting an error "Run-time error 91 : object variable or with block variable not set" on the line "Set rng = wdApp.ActiveDocument.Content"
    Please help me in overcoming the error i'm facing. Also i want to know if that code is a right approach for my requirement . Please help me as this is very important to me.

  4. #4
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Need to create a Excel Macro to import text from Word to Excel

    attach your doc file for testing
    If solved remember to mark Thread as solved

  5. #5
    Forum Contributor
    Join Date
    11-29-2012
    Location
    Coimbatore, India
    MS-Off Ver
    Excel 2010
    Posts
    101

    Re: Need to create a Excel Macro to import text from Word to Excel

    Quote Originally Posted by patel45 View Post
    attach your doc file for testing
    Hi thanks for replying. I'm attaching the files here.
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Need to create a Excel Macro to import text from Word to Excel

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    11-29-2012
    Location
    Coimbatore, India
    MS-Off Ver
    Excel 2010
    Posts
    101

    Re: Need to create a Excel Macro to import text from Word to Excel

    Quote Originally Posted by patel45 View Post
    Please Login or Register  to view this content.
    Hi.. this works fine.

    TheContent = rng.Cells(1).Next.Range.Text

    The above line searches for particular word(TextToFind) and assigning the next row's content into "The Content" variable. Can you please tell me what to do in case i want to assign the next word of the "TextToFind".

    For example consider i'm having some line as Casual Visit $5000

    In this case i'm searching for "Casual visit" and once i find the casual visit i should assign $5000 to "The Content" variable.

  8. #8
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Need to create a Excel Macro to import text from Word to Excel

    You have "Casual Visit $5000" in a cell of the table or in a line ?

  9. #9
    Forum Contributor
    Join Date
    11-29-2012
    Location
    Coimbatore, India
    MS-Off Ver
    Excel 2010
    Posts
    101

    Re: Need to create a Excel Macro to import text from Word to Excel

    Quote Originally Posted by patel45 View Post
    You have "Casual Visit $5000" in a cell of the table or in a line ?
    Hi,

    It's in a cell of table.
    Last edited by sugaprasad; 01-22-2013 at 03:30 AM.

  10. #10
    Forum Contributor
    Join Date
    11-29-2012
    Location
    Coimbatore, India
    MS-Off Ver
    Excel 2010
    Posts
    101

    Re: Need to create a Excel Macro to import text from Word to Excel

    Quote Originally Posted by patel45 View Post
    You have "Casual Visit $5000" in a cell of the table or in a line ?
    Its within a cell. I'm attaching a word document. Attachment name (Highlighted with fields_updated.doc)

    There are two Columns. "ABC" & "Managing"

    I have highlighed the things in yellow color which i want to capture.


    Please help me in capturing them.
    Attached Files Attached Files
    Last edited by sugaprasad; 01-22-2013 at 03:36 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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