Microsoft Office Tutorials and References
In Depth Information
Saving Word Form Data to an Excel Spreadsheet
'Continue when error occurs¶
On Error Resume Next¶
rng.Worksheet.Cells(rowIndex, counter).Value _¶
= ActiveDocument.FormFields(fieldName).Result¶
On Error GoTo 0¶
Next¶
'Save the workbook with the new record¶
wb.Save¶
'Bring Excel to the front¶
objXL.Visible = True¶
objXL.Quit¶
'Clear memory¶
Set ObjExcel = Nothing¶
Set wb = Nothing¶
End Sub¶
Follow these steps:
1. Enter the complete path to the workbook as the value for the constant
xlWorkbook.
Note: The macro runs from a toolbar that displays when a document is created using
the template.
2. Create a table in an Excel worksheet. The first column is reserved for
an incremental record tracking number. Give it an appropriate heading
name, such as “Record”.
3. Select the column heading. Go to Insert | Names | Define and give it
the range name: Start. All positions in the table are calculated from this
point. It need not be cell A1, and it need not be the first worksheet.
4. For the remaining column headings, enter the same names used for the
form fields in the Word form. Be careful to use the exact same spelling
as in the Word form.
Cmb
Tip: Double-click a form field to see its name in the Options dialog box.
5. Save the Excel workbook. Run the macro.
Search JabSto ::




Custom Search