Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I found the below code in this group, provided by Jean-Yves. The OP was
someone named Pepper. It is to import a series of tables from MS Word files, starting with the second row of the table, into Excel. I have a similar task to perform. I tried this and was getting a Compile error at the second line, Dim wdApp As Word.Application The error is User-defined type not defined I couldnt get past this. Furthermore, there is a single line in each of the Word files, above the tables, that I need to imported as well, and would be most suitable if this line went into column A, to the left of the first imported row from each of the Word tables, which would start in Column B of the destination Excel file. I hope I explained the adequately to be understood. The code follows: Sub WordToExcel() Dim wdApp As Word.Application Dim wdDoc As Word.Document Dim x As Integer Dim strFilename As String Dim temp As String Set wdApp = New Word.Application 'initialise counter x = 1 'search for first file in directory strFilename = Dir("C:/Temp/*.doc") 'amemd folder name Do While strFilename < "" Set wdDoc = wdApp.Documents.Open(strFilename) temp = wdDoc.Tables(1).Cell(2, 1).Range.Text 'read word cell Range("A2").Offset(x, 0) = temp temp = wdDoc.Tables(1).Cell(2, 2).Range.Text 'read word cell Range("A2").Offset(x, 1) = temp 'etc wdDoc.Close x = x + 1 strFilename = Dir Loop wdApp.Quit Set wdDoc = Nothing Set wdApp = Nothing End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
importing/linking data from an Access 2003 Query to an Excel 2003 | Excel Discussion (Misc queries) | |||
Importing Alan Beban's code on Arrays; Importing a module or a project | Excel Worksheet Functions | |||
Importing XML into Excel 2003 from a URL | Excel Programming | |||
Jean-Guy question | Excel Discussion (Misc queries) | |||
Importing data from Access to Excel 2003 using code | Excel Programming |