Hello All, I have got lot of MS Word files in a folder eg. C:\Test\<many folders here> I wish to copy and paste the Tables from all the word documents in the above mentioned folder to excel. I found Macro1 (see below) which copy and paste the Table in Excel. My requirement is to get the tables from all the documents from each folder in the path C:\Test\ Can Macro 1 be amended *to copy and paste all tables from each folder in C:\Test\* *MACRO 1 TO IMPORT WORD TABLE* Sub ImportWordTable() On Error GoTo errHandler Dim wordDoc As Object Dim wdFileName As Variant Dim noTble As Integer Dim rowNb As Long Dim colNb As Integer Dim x As Long, y As Long x = 1: y = 1 wdFileName = Application.GetOpenFilename("Word files (*.docx),*.docx", , _ "Browse for file containing table to be imported") 'adjust this to the document type you are after If wdFileName = False Then Exit Sub Set wordDoc = GetObject(wdFileName) With wordDoc noTble = wordDoc.tables.Count If noTble = 0 Then MsgBox "No Tables in this document", vbExclamation, "No Tables to Import" Exit Sub End If For k = 1 To noTble With .tables(k) For rowNb = 1 To .Rows.Count For colNb = 1 To .Columns.Count Cells(x, y) = WorksheetFunction.Clean(.cell(rowNb, colNb).Range.Text) y = y + 1 Next colNb y = 1 x = x + 1 Next rowNb End With x = x + 2 Next End With Set wordDoc = Nothing Exit Sub errHandler: MsgBox "Error in generating tables - " & Err.Number & " - " & Err.Description End Sub *MACRO 2 TO RUN ON ALL THE FOLDERS - this gives me runtime error as shown below* Sub RunOnAllFolders() Dim file Dim path As String Dim MyArray() Dim N As Long path = "C:\Test\" file = Dir(path & "*.docx") ReDim MyArray(0) Do While file <> "" If MyArray(0) = "" Then MyArray(0) = file Else ReDim Preserve MyArray(UBound(MyArray) + 1) MyArray(UBound(MyArray)) = file End If file = Dir() Loop For N = 0 To UBound(MyArray) Documents.Open filename:=path & MyArray(N) *'<<runtime error 429 ActiveX Component can't create Object >>* *Call ImportWordTable* ActiveDocument.Save ActiveDocument.Close file = Dir() Next N End Sub Can the runtime error 429 be rectified from Macro 2 Any help would be appreciated. Regards Nasir 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 http://groups.google.com/group/excel-macros. For more options, visit https://groups.google.com/groups/opt_out.