Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / October 2006

Tip: Looking for answers? Try searching our database.

How export data in a word “text     form field” into excel spreadshe    e

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steve Jones - 19 Oct 2006 04:22 GMT
I have created a Word template and would like to capture the data in the text
form fields by importing it into excel spreadsheet.  How do I do that with
out retyping it in?

What discussion group would be the best to post this question to?
Greg Maxey - 19 Oct 2006 11:35 GMT
Steve,

I am just dipping my toes in the water leaning to connect Word data to
Excel.  Something like this might work where the sample form has three
fields per record.  Change "C" according to the number of fields you will
use.  The first row of the spreadsheet is for the column headings.

Sub ExportToExcel()
Dim oXL As Excel.Application
Dim oWB As Excel.Workbook
Dim oSheet As Excel.Worksheet
Dim myWB As String
Dim oFF As FormField
Dim i As Long
myWB = "C:\myExportBook1.xls"
Set oXL = New Excel.Application
On Error GoTo Err_Handler
Set oWB = oXL.Workbooks.Open(FileName:=myWB)
Set oSheet = oWB.Sheets("Sheet1")
Dim LastRow As Long
LastRow = oSheet.Cells(oSheet.Rows.Count, "C").End(xlUp).Row
i = 1
For Each oFF In ActiveDocument.FormFields
   oSheet.Cells(LastRow + 1, i).Value = oFF.Result
   i = i + 1
Next oFF
oWB.Save
Set oSheet = Nothing
Set oWB = Nothing
oXL.Quit 'Added
Set oXL = Nothing
'Excel.Application.Quit
Exit Sub
Err_Handler:
  MsgBox myWB & " caused a problem. " & Err.Description, vbCritical,
"Error: " _
  & Err.Number
End Sub

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> I have created a Word template and would like to capture the data in
> the text form fields by importing it into excel spreadsheet.  How do
> I do that with out retyping it in?
>
> What discussion group would be the best to post this question to?
Helmut Weber - 19 Oct 2006 15:34 GMT
Hi Steve,

see the posting above:
"Send data from Word to Excel"

Instead of the bookmarks-section
use something like this:

Dim oFld As FormField
For Each oFld In ActiveDocument.range.FormFields
  If oFld.Type = wdFieldFormTextInput Then
        MsgBox oFld.Result ' for testing
  End If
Next

>What discussion group would be the best to post this question to?

I don't think there is an Excel-Word group
or a Word-Excel group. So for special challenges
you might have to ask here or in other Word-groups,
or in the different Excel-groups.

Though putting text from textformfields
into an Excel-workbook is no challenge.

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

Russ - 29 Oct 2006 04:24 GMT
Here are two Google Groups search results:
http://tinyurl.com/yd9ala in Word Groups
http://snipurl.com/10o50 in Excel Groups

> I have created a Word template and would like to capture the data in the text
> form fields by importing it into excel spreadsheet.  How do I do that with
> out retyping it in?
>
> What discussion group would be the best to post this question to?

Signature

Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.