PDA

View Full Version : Solved: Word to Excel



mgonzalez07
08-28-2005, 06:46 PM
Hi, I need to write a macro so that after a user is done filling in a form in Word they can run it and a specific Excel file (a template) will open and specific form text boxes will be copied over to specific cells in the worksheet. Can anyone help?

Jacob Hilderbrand
08-28-2005, 09:07 PM
Try this.

Option Explicit

Sub Macro1()

Dim AppExcel As Object
Dim Wkb As Object

Set AppExcel = CreateObject("Excel.Application")
Set Wkb = AppExcel.Workbooks.Open(FileName:= '<Path and File Name Here>
Wkb.sheets("Sheet1").Range("A1").Value = ActiveDocument.FormFields("Text1").Result
AppExcel.Visible = True

Set Wkb = Nothing
Set AppExcel = Nothing

End Sub

mgonzalez07
09-01-2005, 06:24 PM
The code works great.

Thanks for the help DRJ.