keplan
asked on
Converting tables on a word 201 documents to excel 2010
Hi,
I've a word file which has no of tables with data, I need to export these table's data into excel or SQL table, is there any sort cut to do this?
Regards,
Manjula
I've a word file which has no of tables with data, I need to export these table's data into excel or SQL table, is there any sort cut to do this?
Regards,
Manjula
>>Zones: SQL Server 2008, Microsoft Excel Spreadsheet Software, Microsoft Word<<
Does this have anything to do with SQL Server?
Does this have anything to do with SQL Server?
ASKER
The Microsoft word file got many tables with data, so it is a big task to copy and paste to excel, i'm looking for some kind of export facility directly from word file to excel or table on SQL server database. I can use SSIS from excel file to table, but how could I export tables to excel from word file?
You haven't posted your Word doc, so I don't know exactly what yur data looks like, but this generic macro will run from Excel, and will import all the tables from a Word doc you specify into the active sheet.
Public Sub GetWordTables()
Dim wdDoc As Object 'Word.Document
Dim wksTarget As Excel.Worksheet
Dim rngOut As Excel.Range
Dim tbl As Object 'Word.Table
Const WORD_SOURCE As String = "YOUR FILE LOCATION...\tablesource.docx"
Set wdDoc = GetObject(WORD_SOURCE)
Set wksTarget = ActiveWorkbook.Worksheets("Sheet1") ' or whatever you want
Set rngOut = wksTarget.Cells(1)
For Each tbl In wdDoc.Tables
tbl.Range.Copy
rngOut.Select
rngOut.PasteSpecial xlPasteValues
Set rngOut = rngOut.Offset(Selection.Rows.Count, 0)
Next tbl
Set wdDoc = Nothing
End Sub
ASKER
Fantastic answer andrewssd3!
if you could help me on this as well. the unique identifier of each table is the Headline above the word table and also not in the column heading. your macro does the great job to copy all the table to a excel worksheet, since my programe knowledge is bit less, i would like to ask you how do I modify to copy the heading of each tables on the word file which is not on the column's heading.
Thanks,
Sample table
Heading1
2009/2010 2010/2011 % change 2009/2010 2010/2011 % change
data data data data data
if you could help me on this as well. the unique identifier of each table is the Headline above the word table and also not in the column heading. your macro does the great job to copy all the table to a excel worksheet, since my programe knowledge is bit less, i would like to ask you how do I modify to copy the heading of each tables on the word file which is not on the column's heading.
Thanks,
Sample table
Heading1
2009/2010 2010/2011 % change 2009/2010 2010/2011 % change
data data data data data
Heading
2009/2010 2010/2011 % change 2009/2010 2010/2011 % change
What do you want to do with the Heading text? - you could create a new first column which has that heading text repeated for each row of the table. Also do you want any of the heading rows from the table itself, or shall I just throw those away?
ASKER
You are exactly talking about what I need, yes, I need to repeat the heading on each row for the table it belong to. and when the new table found it should get the new heading belong to that table. So the heading rows can thrown away. I would like to see only a one occurence of the heading rows.
Thanks for your help.
Thanks for your help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
excellent solution, much appreciated for your help
Have you tried a straight cut and paste or are you looking for a programmatic way to do it on a regular basis?