By: Shamima Sultana

In reply to SANTOSH KUMAR DWIVEDI.

Hello Shantosh Kumar Dwivedi,

Thank you for your kind words! I’m glad you found the article helpful. For your specific requirements, you can achieve this using Mail Merge with VBA in Word, along with some automation techniques. Here’s how you can approach each point:

Populate all rows into a single Word document:
1. Instead of creating separate Word files, use the NEXT RECORD field in Mail Merge to insert all rows into the same document.
2. Alternatively, a VBA macro can loop through the Excel data and append each row dynamically to a designated section of the Word document.

Dynamically select different Excel files:
1. This can be handled by adding a VBA script that allows the user to browse and select an Excel file dynamically.
2. The script would ensure that the selected file maintains the same structure (column names) while updating the data.

Repeat only a selected portion of the Word document:
1. You can achieve this by inserting a Content Control or a specific table within Word where the repeated content is dynamically inserted.
2. Since some sections are populated via Quick Parts (Document Property in SharePoint), ensure that the VBA script or Mail Merge only updates the designated area while keeping the SharePoint metadata intact.