republican-creole
site Search:


 
    All Forums Hot Topics Gallery






how-to block ads


 
Search Topic:
Uniqs:
374
Share Topic
Posting?
Post a:
Post a:
Links: ·MS Apps FAQ ·Windows XP FAQ ·Windows 7 FAQ ·Windows Home ·Office Home
AuthorAll Replies


Grey Area

join:2003-11-18
UK

[Excel] Extracting data from Word Docs into an Excel sheet

I have a folder of word documents with data in them, they are all in the same format and have fields for first name, last name, address etc.

I would like to import the data from them into an Excel spreadsheet, transferring the fields to columns and having one row for each word document.

I'm assuming the best way would be a VB macro in the Target Excel sheet, but whilst my VB is okay, it's a bit ropey on the file handling side. Can anyone start me off?


Grey Area

join:2003-11-18
UK

Making some progress...Activedocument.SaveFormsData = True has got me part of the way.

Anyone know if you can run a macro from a hyperlink in Word? I can find lots of ways to do it in Excel, but not Word...



Grey Area

join:2003-11-18
UK

Progress...this will make a CSV file for each doc file...but I haven't yet found a way to make a single file with all the data in;

Sub SaveFormData()
Dim fs As Object
Dim oFolder As Object
Dim tFolder As Object
Dim oFile As Object
Dim strDocName As String
Dim intPos As Integer
Dim locFolder As String
Dim Response As String
On Error Resume Next
locFolder = InputBox("Enter the folder path to DOCs", "Form Data Conversion", "Copy folder here")

Response = MsgBox("Click OK to save all forms data", vbOKCancel, "Save Forms Data")
If Response = "Cancel" Then End

Application.ScreenUpdating = False
Set fs = CreateObject("Scripting.FileSystemObject")
Set oFolder = fs.GetFolder(locFolder)
Set tFolder = fs.CreateFolder(locFolder & "Converted")
Set tFolder = fs.GetFolder(locFolder & "Converted")
For Each oFile In oFolder.Files
Dim d As Document
Set d = Application.Documents.Open(oFile.Path)
ActiveDocument.SaveFormsData = True
strDocName = ActiveDocument.Name
intPos = InStrRev(strDocName, ".")
strDocName = Left(strDocName, intPos - 1)
strDocName = strDocName & ".txt"
ChangeFileOpenDirectory tFolder
ActiveDocument.SaveAs FileName:=strDocName, FileFormat:=wdFormatText
d.Close SaveChanges:=wdDoNotSaveChanges
ChangeFileOpenDirectory oFolder
Next oFile
Application.ScreenUpdating = True
End Sub


Wednesday, 22-May 05:42:37 Terms of Use & Privacy | feedback | contact | Hosting by nac.net - DSL,Hosting & Co-lo
over 13.5 years online © 1999-2013 dslreports.com.
Most commented news this week
Hot Topics