PDA

View Full Version : Copying data from Excel to pre-existing Word table



fa2020
07-24-2020, 05:45 AM
Hi friends,
I have provided a sample excel and word file for better understanding the task I want to do. I have an Excel file which contains some information about PM services. In the provided Word file, you see that there is a page with a table (Pre-Existing).
I want to copy each cell in the Excel file to the corresponding cell in the Word table. My Excel file may contain around 1300 rows, so I need to add the same Word page with the same text and table style as I need to fill all those 1300 rows in Word file (the sample file has 99 data rows).
Please guide me to write a VBA code for automating this task.

snb
07-24-2020, 06:39 AM
You'd better paste the data into an empty Word document and format it afterwards:


Sub M_snb()
Sheet1.Cells(1).CurrentRegion.Offset(1).SpecialCells(2).Copy

With GetObject("J:\download\Test(1).docx")
.Paragraphs.last.Range.Paste
End With
End Sub