PDA

View Full Version : Data from Word to Excel



asingh
12-28-2007, 04:50 PM
Hi,

I want to pick up some freezed fields from a word document and paste them into an allready saved excel file, which resides in the same folder.

Logic....how...????

1. I get the path of the word document useing activedocument.path.
2. Capture the freezed fields values in distinct variables.
3. Open the all ready saved excel.
4. Find the last row in a specific column (s) in Excel.
5. Paste the values in Excel.
6. Save and close the workbook.

Thanks an lot for the help....

regards,
asingh

fumei
12-30-2007, 02:57 AM
"freezed fields"????

Do you mean the document is locked (protected for forms)?

If these are formfields...and BTW...always try and be specific...then you simply take the value of the formfields (.Result) and dump it into your variables. It is very straightforward.
Dim myVar As String
myVar = ActiveDocument.Formfields("whatever").Result

Done. The value of the variable equals the value of the formfield. There is not even any need to unprotect the document. The .Result property can be read without unprotecting.

asingh
01-01-2008, 04:08 AM
Hi,

Yes the document is locked for the fields. So users can tab to the fields...getting the values into variables is not an issue. I want to know the excel part as mentioned in 3,4,5,6....

fumei
01-02-2008, 10:59 AM
Do a search.

You create an instance of Excel.
You open the Excel file.
You put the values into the column you want.
You save the workbook.
You Quit the instance of Excel.
You destroy the instance of Excel.