Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-24-2015, 05:19 AM
Atomizer Atomizer is offline Extracting Data from Word Documents Windows 7 32bit Extracting Data from Word Documents Office 2010 32bit
Novice
Extracting Data from Word Documents
 
Join Date: May 2011
Location: London UK
Posts: 4
Atomizer is on a distinguished road
Default Extracting Data from Word Documents

Hi I have a folder with a 100 word documents, is there a way I can extra certain information from the files and deposit it in excel. I want to take the name, address and amount I have quoted from each file then add this to a new row in an excel file. Is this asking too much of the software ? David
Reply With Quote
  #2  
Old 08-24-2015, 09:17 AM
Charles Kenyon Charles Kenyon is offline Extracting Data from Word Documents Windows 8 Extracting Data from Word Documents Office 2013
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,125
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Unless there is some way for the software to identify these bits of data, it is asking too much.
Reply With Quote
  #3  
Old 08-24-2015, 04:26 PM
Guessed's Avatar
Guessed Guessed is offline Extracting Data from Word Documents Windows 7 32bit Extracting Data from Word Documents Office 2010 32bit
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,969
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

It is possible to do but you would need to write a macro that opens each file, finds the relevant information and copies it to your excel sheet.

This is not a trivial exercise but if your 100 documents are very consistent it is certainly possible.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #4  
Old 08-24-2015, 04:49 PM
macropod's Avatar
macropod macropod is offline Extracting Data from Word Documents Windows 7 64bit Extracting Data from Word Documents Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

For some macros that show how you might go about this for a single document, see:
https://www.msofficeforums.com/word-...acters-up.html
https://www.msofficeforums.com/word/...doc-excel.html
For code demonstrating how to process an entire folder and export Word data to Excel, see:
https://www.msofficeforums.com/word-...html#post64259

If your data are held in formfields or content controls, the following Excel macro might be more useful. It extracts data from all formfields & content controls in all Word documents in the selected folder and populates the first available row in the active Excel worksheet with the data for each document.
Code:
Sub GetFormData()
'Note: this code requires a reference to the Word object model.
'See under the VBE's Tools|References.
Application.ScreenUpdating = False
Dim wdApp As New Word.Application, wdDoc As Word.Document
Dim FmFld As Word.FormField, CCtrl As Word.ContentControl
Dim strFolder As String, strFile As String
Dim WkSht As Worksheet, c As Long, r As Long
strFolder = GetFolder
If strFolder = "" Then Exit Sub
Set WkSht = ActiveSheet
r = WkSht.Cells(WkSht.Rows.Count, 1).End(xlUp).Row
strFile = Dir(strFolder & "\*.doc", vbNormal)
While strFile <> ""
  r = r + 1
  Set wdDoc = wdApp.Documents.Open(FileName:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=False)
  With wdDoc
    c = 0
    For Each FmFld In .FormFields
      c = c + 1
      With FmFld
        Select Case .Type
          Case Is = wdFieldFormCheckBox
            WkSht.Cells(r, c) = .CheckBox.Value
          Case Else
            WkSht.Cells(r, c) = .Result
        End Select
      End With
    Next
    For Each CCtrl In .ContentControls
      c = c + 1
      With CCtrl
        Select Case .Type
          Case Is = wdContentControlCheckBox
            WkSht.Cells(r, c) = .Checked
          Case wdContentControlDate, wdContentControlDropdownList, wdContentControlRichText, wdContentControlText
            WkSht.Cells(r, c) = .Range.Text
          Case Else
        End Select
      End With
    Next
    .Close SaveChanges:=False
  End With
  strFile = Dir()
Wend
wdApp.Quit
Set wdDoc = Nothing: Set wdApp = Nothing: Set WkSht = Nothing
Application.ScreenUpdating = True
End Sub
 
Function GetFolder() As String
    Dim oFolder As Object
    GetFolder = ""
    Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Choose a folder", 0)
    If (Not oFolder Is Nothing) Then GetFolder = oFolder.Items.Item.Path
    Set oFolder = Nothing
End Function
If you want to record the document's name as part of the data, change:
c = 0
to:
c = 1: WkSht.Cells(r, c) = strFile
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Extracting Data from Word Documents Extracting data, pivot tables, and maybe VBA help? rbexcelhelp Excel Programming 3 05-09-2015 12:13 AM
Extracting Data from Word Documents extracting data from word docs stubevh Word 2 03-04-2015 06:27 PM
Extracting Data from Word Documents formula writing for extracting data jennamae Excel 1 11-15-2013 08:40 PM
Extracting Data from Word Documents Extracting data from excel Eric855 Word 6 07-25-2013 08:02 AM
Extracting Contacts Data from Excel Caesar Outlook 1 05-08-2011 05:54 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:44 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft