Results 1 to 10 of 10
  1. #1
    2 Star Lounger
    Join Date
    Jun 2011
    Posts
    188
    Thanks
    62
    Thanked 0 Times in 0 Posts

    copy word files data to excel

    Hi All,

    I need a code that copies all the word files data from the speacfic folder to one excel file.


    Thanks and Regards,
    farrukh

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts
    The means will depend a lot on the structur of the data in the individual word files...

    For an example of how to do this look at the code at http://windowssecrets.com/forums/sho...l=1#post489472. This pulls from various word tables into an excel table. It may be more complicated than you need, but that makes it easier to apply...

    Steve

    PS if nothing else please post an example word doc and the resulting excel workbook that should comes from that word doc...
    Last edited by sdckapr; 2011-06-27 at 17:02. Reason: added PS

  3. #3
    2 Star Lounger
    Join Date
    Jun 2011
    Posts
    188
    Thanks
    62
    Thanked 0 Times in 0 Posts
    Sir Steve,

    I have the same template of all the word files in the folder each word file contain 9 tables, i want to pick the tables or the text because in text i have the data for the date ( which give me the idea that this table belongs to that date)

    Thanks
    farrukh

  4. #4
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts
    Then adapting the code in the linked post should work. It works on several tables in the Word file and puts them into an excel table.

    If you need help adapting, you need to provide a sample word doc with the tables of interest and an excel file showing the desired output from the template...

    Steve

  5. #5
    2 Star Lounger
    Join Date
    Jun 2011
    Posts
    188
    Thanks
    62
    Thanked 0 Times in 0 Posts
    Sir Steve,
    I did not find any code in that link can you please help me out...

    http://windowssecrets.com/forums/sho...l=1#post489472

    Thanks
    farrukh

  6. #6
    2 Star Lounger
    Join Date
    Jun 2011
    Posts
    188
    Thanks
    62
    Thanked 0 Times in 0 Posts

    Thumbs up copy word files data to excel

    Sir Steve,
    I have attached the sample file.

    Thanks
    farrukh
    Attached Files Attached Files

  7. #7
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts
    Have you tried adapting the solution in the earlier post? This still seems to me to be the place to start...

    I am a little confused, in an earlier posts you mentioned they had 9 tables in them. This one has 26 tables in it along with the text. Are the number of tables variable? Are the tables all identical or did you just copy the same data and they are meant to represent different data sets in the sample and in the real files, they are different.

    And what should the Excel file look like from this sample?

    Steve
    PS another "simple solution" may be to ask the person creating the word file if they have the original data in a spreadsheet and ask them to send it to you. They may be cutting and pasting from excel into Word and have the data readily available in a form you can use or modify more easily....
    Last edited by sdckapr; 2011-06-29 at 05:48. Reason: Added PS

  8. The Following User Says Thank You to sdckapr For This Useful Post:

    farrukh (2011-06-30)

  9. #8
    2 Star Lounger
    Join Date
    Jun 2011
    Posts
    188
    Thanks
    62
    Thanked 0 Times in 0 Posts
    Sir Steve,

    I made just a sample file in original file the table structure is the same all the reports are in the same pattern maximum i have 26 tables some file has 9 some has 5 tables. I want that all the word files data will come in one excel file,paste one word file then below next next and so on...

    Is it possible that i will get the text as well, i have tried my self and make the code to get one word file data, can you please modify it according to my need? the code is below

    Code:
    Option Explicit
    Sub GET_DATA_WORDFILE()
    
      Dim MyWd As Object
    
    Set MyWd = GetObject("C:\ENGDATA\PDMS_Upload\Data_loading\BLOCK22\Block22_Dly_Report.doc")
      MyWd.ActiveWindow.Selection.WholeStory
      MyWd.ActiveWindow.Selection.Copy
      
      Sheets("Sheet1").Range("A1").PasteSpecial xlPasteValues
    End Sub
    Thanks
    farrukh

  10. #9
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts
    If your intent is to loop through all the DOC files in that folder and copy and paste the entire thing, you can add the loop to your existing code:

    Code:
    Option Explicit
    Sub GetDataFromWordDoc()
      Dim sPath As String
      Dim sFile As String
      Dim MyWd As Object
      sPath = "C:\ENGDATA\PDMS_Upload\Data_loading\BLOCK22\"
      sFile = Dir(sPath & "*.doc")
      Do While sFile <> ""
        Set MyWd = GetObject(sPath & sFile)
        MyWd.ActiveWindow.Selection.WholeStory
        MyWd.ActiveWindow.Selection.Copy
        Sheets("Sheet1").Cells.SpecialCells(xlCellTypeLastCell). _
          Offset(1, 1).End(xlToLeft).PasteSpecial xlPasteValues
        sFile = Dir
      Loop
      Set MyWd = Nothing
    End Sub
    If your intent is something else you will have to elaborate...

  11. The Following User Says Thank You to sdckapr For This Useful Post:

    farrukh (2011-06-30)

  12. #10
    2 Star Lounger
    Join Date
    Jun 2011
    Posts
    188
    Thanks
    62
    Thanked 0 Times in 0 Posts
    Sir Steve,

    Awesome this exactly iam looking for

    Thank you so much for your kind help, May God give you reward...

    Regards,
    farrukh

Posting Permissions

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