View Single Post
 
Old 02-04-2019, 08:11 AM
Kenneth Hobson Kenneth Hobson is offline Windows 10 Office 2016
Advanced Beginner
 
Join Date: Jun 2018
Posts: 37
Kenneth Hobson is on a distinguished road
Default

You have to change the code to suit your needs. I had to make guesses.

Code:
 p = "c:\MyFiles\Word\sb\sb"
  dat = "c:\MyFiles\Excel\Dat\dat.xls"
  sql = "SELECT * FROM 'Sheet1$'"
  Set r = Range("A2", Cells(Rows.Count, "A").End(xlUp))
p is the path to your docx files with the first 2 letters of your docx filename at the end, sb.

Dat is the full path to your excel data file.

sql gets the data from all of sheet1 in your dat file.

r is the range A2 and down from the current sheet with the suffix docx filenames, 1,2,3, etc.

The code goes into a Module as does the MergeRun() code.
Reply With Quote