

Copy only the Content and paste it in Word Document as Content. Formatting in Word While pasting Copied Range from Excelġ.Copy the Excel Range as Picture and paste it in word Doc.Copy only the Content and paste it in Word Document as Content.Also while pasting in the word Document you can format the Doc as per your requirement. Here there are two possible way of copying and pasting in Word Document. Now in this Article i am going to write a function will Select a Range from Excel and paste the content in a New Word Document. WdFileName = Application.GetOpenFilename("Word files (*.docx),*.docx",, _Ĭells(resultRow, iCol) = WorksheetFunction.Clean(.cell(iRow, iCol).Range.In Previous Article we saw how to Copy Content from a Word Document and Paste in in to the Active Workbook. Thank you so much Damon and modified it to open docx files, moved a worksheet clear line after checking for escape by user. Next trick: working out how to extract a table within a table from Word. "Enter the table to start from", "Import Word Table", "1")Ĭells(resultRow, iCol) = WorksheetFunction.Clean(.cell(iRow, iCol).Range.Text) TableNo = InputBox("This Word document contains " & tableNo & " tables." & vbCrLf & _ I changed this one with an addition to loop through all tables (starting from the chosen table): Option Explicitĭim tableNo As Integer 'table number in Word But for now I am hoping it is all one continuous table and will not require any modification.

If your document contains many tables, as would be the case if your 100+ page table is actually a separate table on each page, this code could easily be modified to read all the tables. Run the macro from the Excel interface as you would any other (Alt-TMM). To do this, go to the VBA (keyboard Alt-TMV), insert a macro module (Alt-IM), and paste the code into the code pane. This macro should be inserted into Excel (not Word) and put into a standard macro module rather than into the worksheet or workbook event code modules.

'copy cell contents from Word table cells to Excel cellsĬells(iRow, iCol) = WorksheetFunction.Clean(.cell(iRow, iCol).Range.Text) "Enter table number of table to import", "Import Word Table", "1") TableNo = InputBox("This Word document contains " & TableNo & " tables." & vbCrLf & _ MsgBox "This document contains no tables", _ Set wdDoc = GetObject(wdFileName) 'open Word file If wdFileName = False Then Exit Sub '(user cancelled import file browser) "Browse for file containing table to be imported") WdFileName = Application.GetOpenFilename("Word files (*.doc),*.doc",, _ Sub ImportWordTable()ĭim TableNo As Integer 'table number in Wordĭim iCol As Integer 'column index in Excel It prompts you for the word document as well as the table number if Word contains more than one table. Here is some code that reads a table from Word into the active worksheet of Excel.
