Hello All,
I am using Office 2010 and have found this code which works perfect
But I need the following amendments to the code

1) The code should *read all the files in the Folder* - now it runs on a 
single word document
2) It should paste the *All Word table Data under the last available Row on 
Sheet1*

Following is the code which needs to be amended:

Sub ImportTable()
Dim wdDoc As Object
Dim wdTbl As Object
Dim wdFileName As Variant
Dim TableNo As Integer 'table number in Word
Dim cRow As Long 'row index in Excel
Dim cCol As Integer 'column index in Excel
Dim wRow As Long 'row index in Excel


wdFileName = Application.GetOpenFilename("Word files (*.doc),*.doc", , _
"Browse for file containing table to be imported")

If wdFileName = False Then Exit Sub '(user cancelled import file browser)

Set wdDoc = GetObject(wdFileName) 'open Word file
cRow = 0

With wdDoc
    For Each wdTbl In wdDoc.tables
        With wdTbl
        'Test for To in Table Cell 1
        If InStr(wdTbl.Cell(1, 1).Range.Text, "To") Then
        
            'copy cell contents from Word table cells to Excel cells
            For wRow = 1 To .Rows.Count
                cRow = cRow + 1
                For cCol = 1 To .Columns.Count
                    Cells(cRow, cCol) = WorksheetFunction.Clean(.Cell(wRow, 
cCol).Range.Text)
                Next cCol
            Next wRow
        End If
        End With
    cRow = cRow + 1
    Next
End With

Set wdDoc = Nothing
Set wdTbl = Nothing
End Sub

Thanks in advance

Rashid Khan

-- 
Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
https://www.facebook.com/discussexcel

FORUM RULES

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Jobs posting is not allowed.
6) Sharing copyrighted material and their links is not allowed.

NOTE  : Don't ever post confidential data in a workbook. Forum owners and 
members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups "MS 
EXCEL AND VBA MACROS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to excel-macros+unsubscr...@googlegroups.com.
To post to this group, send email to excel-macros@googlegroups.com.
Visit this group at https://groups.google.com/group/excel-macros.
For more options, visit https://groups.google.com/d/optout.

Reply via email to