+ Reply to Thread
Results 1 to 2 of 2

Thread: macro to take data from tables in word file to excel file

  1. #1
    Registered User
    Join Date
    09-23-2009
    Location
    liverpool, england
    MS-Off Ver
    Excel 2003
    Posts
    78

    macro to take data from tables in word file to excel file

    Hello

    I was after a little help if possible.

    The macro I am trying to make will take data from the word file “606letter practice” and then update the excel file “practice pocva”.

    The word file is a template letter that gets updated with new generated information. What I want it to do is take selected information and then update the next available line.

    In the word file, table 2, row 1 column 2, data should be inputted in the next available line on excel file column 1

    Table 1 row 3 column 3 – inputted to column 2 excel

    table 3 row 2 column 1- input column 3 excel with the word “list”

    table 3 row 5 columm 1 input column 3 excel with the word “ISAC”

    table 3 row 8 column 1 input column 3 excel with the word “ISAA”


    I hope this all makes sense , any questions please ask, and any help really would be appreciated. I have attached a mock up with a before and after.

    kind regards

    Joe
    Attached Files Attached Files

  2. #2
    Forum Guru mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2007/2010
    Posts
    3,005

    Re: macro to take data from tables in word file to excel file

    Not sure that I fully understood but may the code below might help. You will need to make a reference to Word (tools -references) , have the Word Document open and Excel open on the correct sheet.

    Sub Test()
    Dim WordApp As Word.Application
    Set WordApp = GetObject(, "Word.Application")
    Cells(Rows.Count, 1).End(xlUp).Offset(1, 0) = WordApp.ActiveDocument.Tables(2).Cell(1, 2)
    Cells(Rows.Count, 1).End(xlUp).Offset(0, 1) = WordApp.ActiveDocument.Tables(1).Cell(3, 3)
    Cells(Rows.Count, 1).End(xlUp).Offset(0, 2) = WordApp.ActiveDocument.Tables(3).Cell(2, 1)
    Cells(Rows.Count, 1).End(xlUp).Offset(0, 3) = WordApp.ActiveDocument.Tables(3).Cell(5, 1)
    Set WordApp = Nothing
    End Sub
    Martin

    Eighty Twenty Spreadsheet Automation http://homepage.ntlworld.com/martin.rice1/ for all your Excel customisation and consulting needs.

    If my solution has saved you time and/or money, please consider donating to Cancer Research UK.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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.2.0