Importing a cell from a word table into an excel worksheet

jinx2013

New Member
Joined
Jun 5, 2013
Messages
1
How can i modify the code below so it does the following:
- Extract data from all the documents within a folder- Not a single file at the time. I have to process 6000 word documents.:(
- Copies only the data within the cell that starts with "External References"- instead of every table within a document.
- Paste the name of the document in an adjacent cell to what is being imported.
- Each cell being copied needs to be pasted one after another in rows.

Im just a secretary and im not skilled in <acronym title="visual basic for applications" style="border-width: 0px 0px 1px; border-bottom-style: dotted; border-bottom-color: rgb(0, 0, 0); cursor: help;">VBA</acronym>,
Can you please help me??


Sub ImportWordTable3()'Import all tables to a single sheetDim wdDoc As ObjectDim wdFileName As VariantDim TableNo As Integer 'table number in WordDim iRow As Long 'row index in WordDim jRow As Long 'row index in ExcelDim iCol As Integer 'column index in ExcelwdFileName = 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 fileWith wdDoc If wdDoc.tables.Count = 0 Then MsgBox "This document contains no tables", _ vbExclamation, "Import Word Table" Else jRow = 0 Sheets.Add after:=Sheets(Worksheets.Count) For TableNo = 1 To wdDoc.tables.Count With .tables(TableNo)'copy cell contents from Word table cells to Excel cells For iRow = 1 To .Rows.Count jRow = jRow + 1 For iCol = 1 To .Columns.Count On Error Resume Next ActiveSheet.Cells(jRow, iCol) = WorksheetFunction.Clean(.cell(iRow, iCol).Range.Text) On Error GoTo 0 Next iCol Next iRow End With jRow = jRow + 1 Next TableNo End IfEnd WithSet wdDoc = NothingEnd Sub</pre>
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Forum statistics

Threads
1,216,529
Messages
6,131,197
Members
449,634
Latest member
sunilj56

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top