Home |
Search |
Today's Posts |
#1
![]() |
|||
|
|||
![]()
I have forms that have been filled out in Microsoft Word 2000. I would like
to extract the data from all the forms in a folder and put it in a single Excel spreadsheet. Can it be done? |
#2
![]() |
|||
|
|||
![]()
If you put all of the documents into a folder by themselves and then run the
following macro, selecting that folder when prompted to do so, it should create a new document with a paragraph for each of the documents containing the data from the formfields with each piece of data separated by a tab. You can then copy and paste that information into Excel. Dim mydoc As Document Dim target As Document Dim i As Long 'let user select a path With Dialogs(wdDialogCopyFile) If .Display() -1 Then Exit Sub MyPath = .Directory End With 'strip quotation marks from path Set target = Documents.Add If Len(MyPath) = 0 Then Exit Sub If Asc(MyPath) = 34 Then MyPath = Mid$(MyPath, 2, Len(MyPath) - 2) End If 'get files from the selected path 'and insert them into the doc MyName = Dir$(MyPath & "*.*") Do While MyName "" Set mydoc = Documents.Open(MyPath & MyName) For i = 1 To mydoc.FormFields.Count - 1 target.Range.InsertAfter mydoc.FormFields(i).result & vbTab Next i target.Range.InsertAfter mydoc.FormFields(i).result & vbCr mydoc.Close wdDoNotSaveChanges MyName = Dir$ Loop -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "bbbitt" wrote in message ... I have forms that have been filled out in Microsoft Word 2000. I would like to extract the data from all the forms in a folder and put it in a single Excel spreadsheet. Can it be done? |
#3
![]() |
|||
|
|||
![]()
I'm a novice programmer as well and can really use the code provided . . . in
fact, I already have. However, I do get an error because the documents I am opening have tables instead of FormFields (not even sure what these are). How do I extract data from a table? "Doug Robbins" wrote: If you put all of the documents into a folder by themselves and then run the following macro, selecting that folder when prompted to do so, it should create a new document with a paragraph for each of the documents containing the data from the formfields with each piece of data separated by a tab. You can then copy and paste that information into Excel. Dim mydoc As Document Dim target As Document Dim i As Long 'let user select a path With Dialogs(wdDialogCopyFile) If .Display() -1 Then Exit Sub MyPath = .Directory End With 'strip quotation marks from path Set target = Documents.Add If Len(MyPath) = 0 Then Exit Sub If Asc(MyPath) = 34 Then MyPath = Mid$(MyPath, 2, Len(MyPath) - 2) End If 'get files from the selected path 'and insert them into the doc MyName = Dir$(MyPath & "*.*") Do While MyName "" Set mydoc = Documents.Open(MyPath & MyName) For i = 1 To mydoc.FormFields.Count - 1 target.Range.InsertAfter mydoc.FormFields(i).result & vbTab Next i target.Range.InsertAfter mydoc.FormFields(i).result & vbCr mydoc.Close wdDoNotSaveChanges MyName = Dir$ Loop -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "bbbitt" wrote in message ... I have forms that have been filled out in Microsoft Word 2000. I would like to extract the data from all the forms in a folder and put it in a single Excel spreadsheet. Can it be done? |
#4
![]() |
|||
|
|||
![]()
Thanks, Doug. The macro worked perfectly. -Brenda
"Doug Robbins" wrote: If you put all of the documents into a folder by themselves and then run the following macro, selecting that folder when prompted to do so, it should create a new document with a paragraph for each of the documents containing the data from the formfields with each piece of data separated by a tab. You can then copy and paste that information into Excel. Dim mydoc As Document Dim target As Document Dim i As Long 'let user select a path With Dialogs(wdDialogCopyFile) If .Display() -1 Then Exit Sub MyPath = .Directory End With 'strip quotation marks from path Set target = Documents.Add If Len(MyPath) = 0 Then Exit Sub If Asc(MyPath) = 34 Then MyPath = Mid$(MyPath, 2, Len(MyPath) - 2) End If 'get files from the selected path 'and insert them into the doc MyName = Dir$(MyPath & "*.*") Do While MyName "" Set mydoc = Documents.Open(MyPath & MyName) For i = 1 To mydoc.FormFields.Count - 1 target.Range.InsertAfter mydoc.FormFields(i).result & vbTab Next i target.Range.InsertAfter mydoc.FormFields(i).result & vbCr mydoc.Close wdDoNotSaveChanges MyName = Dir$ Loop -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "bbbitt" wrote in message ... I have forms that have been filled out in Microsoft Word 2000. I would like to extract the data from all the forms in a folder and put it in a single Excel spreadsheet. Can it be done? |
#5
![]() |
|||
|
|||
![]()
Take a look at the thread "Extracting Text from Word Document" in the
microsoft.public.word.vba.general newsgroup: -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "wjgaddis" wrote in message ... I'm a novice programmer as well and can really use the code provided . . . in fact, I already have. However, I do get an error because the documents I am opening have tables instead of FormFields (not even sure what these are). How do I extract data from a table? "Doug Robbins" wrote: If you put all of the documents into a folder by themselves and then run the following macro, selecting that folder when prompted to do so, it should create a new document with a paragraph for each of the documents containing the data from the formfields with each piece of data separated by a tab. You can then copy and paste that information into Excel. Dim mydoc As Document Dim target As Document Dim i As Long 'let user select a path With Dialogs(wdDialogCopyFile) If .Display() -1 Then Exit Sub MyPath = .Directory End With 'strip quotation marks from path Set target = Documents.Add If Len(MyPath) = 0 Then Exit Sub If Asc(MyPath) = 34 Then MyPath = Mid$(MyPath, 2, Len(MyPath) - 2) End If 'get files from the selected path 'and insert them into the doc MyName = Dir$(MyPath & "*.*") Do While MyName "" Set mydoc = Documents.Open(MyPath & MyName) For i = 1 To mydoc.FormFields.Count - 1 target.Range.InsertAfter mydoc.FormFields(i).result & vbTab Next i target.Range.InsertAfter mydoc.FormFields(i).result & vbCr mydoc.Close wdDoNotSaveChanges MyName = Dir$ Loop -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "bbbitt" wrote in message ... I have forms that have been filled out in Microsoft Word 2000. I would like to extract the data from all the forms in a folder and put it in a single Excel spreadsheet. Can it be done? |
#6
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
Doug:
Thanks for the post. I ran your macro, but saved the result as a text file, then imported it into an Access table. Works great! -- Julie "Doug Robbins" wrote: If you put all of the documents into a folder by themselves and then run the following macro, selecting that folder when prompted to do so, it should create a new document with a paragraph for each of the documents containing the data from the formfields with each piece of data separated by a tab. You can then copy and paste that information into Excel. Dim mydoc As Document Dim target As Document Dim i As Long 'let user select a path With Dialogs(wdDialogCopyFile) If .Display() -1 Then Exit Sub MyPath = .Directory End With 'strip quotation marks from path Set target = Documents.Add If Len(MyPath) = 0 Then Exit Sub If Asc(MyPath) = 34 Then MyPath = Mid$(MyPath, 2, Len(MyPath) - 2) End If 'get files from the selected path 'and insert them into the doc MyName = Dir$(MyPath & "*.*") Do While MyName "" Set mydoc = Documents.Open(MyPath & MyName) For i = 1 To mydoc.FormFields.Count - 1 target.Range.InsertAfter mydoc.FormFields(i).result & vbTab Next i target.Range.InsertAfter mydoc.FormFields(i).result & vbCr mydoc.Close wdDoNotSaveChanges MyName = Dir$ Loop -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "bbbitt" wrote in message ... I have forms that have been filled out in Microsoft Word 2000. I would like to extract the data from all the forms in a folder and put it in a single Excel spreadsheet. Can it be done? |
#7
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
Hi Doug -
I am not very familiar with macros, however I am in desperate need of doing this also!! Can you tell me where I place the macro? Thanks in advance! Cheryl "Doug Robbins" wrote: If you put all of the documents into a folder by themselves and then run the following macro, selecting that folder when prompted to do so, it should create a new document with a paragraph for each of the documents containing the data from the formfields with each piece of data separated by a tab. You can then copy and paste that information into Excel. Dim mydoc As Document Dim target As Document Dim i As Long 'let user select a path With Dialogs(wdDialogCopyFile) If .Display() -1 Then Exit Sub MyPath = .Directory End With 'strip quotation marks from path Set target = Documents.Add If Len(MyPath) = 0 Then Exit Sub If Asc(MyPath) = 34 Then MyPath = Mid$(MyPath, 2, Len(MyPath) - 2) End If 'get files from the selected path 'and insert them into the doc MyName = Dir$(MyPath & "*.*") Do While MyName "" Set mydoc = Documents.Open(MyPath & MyName) For i = 1 To mydoc.FormFields.Count - 1 target.Range.InsertAfter mydoc.FormFields(i).result & vbTab Next i target.Range.InsertAfter mydoc.FormFields(i).result & vbCr mydoc.Close wdDoNotSaveChanges MyName = Dir$ Loop -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "bbbitt" wrote in message ... I have forms that have been filled out in Microsoft Word 2000. I would like to extract the data from all the forms in a folder and put it in a single Excel spreadsheet. Can it be done? |
Reply |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Please give us REVEAL CODES like WORD PERFECT not reveal codes in. | Microsoft Word Help | |||
Making Word do something that Wordperfect can do | New Users | |||
Envelope Address | New Users | |||
In Word, how can I see all files (*.*) in "save as"? | New Users | |||
creating forms | Microsoft Word Help |