0

I'm trying to create a one-to-many merge in Word using Excel VBA. The form works as expected when manually running the process in Word 2013.

When I try to automate using VBA in Excel 2013, it defaults and inserts page breaks for each new row in the Excel Spreadsheet.

Here is my code altered from the source following the code block:

Dim cDir As String
Dim ThisFileName As String

Const WTempName = "HCCMailMerge.docx" 'This is Word Templates name
Dim NewFileName As String

NewFileName = "Testing123"

' Setup directory
cDir = ActiveWorkbook.Path + "\"
ThisFileName = ThisWorkbook.Name

'Open Word Template
Set objMMMD = objWord.Documents.Open(cDir + WTempName)
objMMMD.Activate

'Merge the data
With objMMMD.MailMerge
    .OpenDataSource _
        Name:=cDir + ThisFileName, _
        SQLStatement:="SELECT * FROM `Data$`"
    .Destination = wdSendToNewDocument
    .MainDocumentType = wdCatalog
    .Execute Pause:=False
End With

Automating Mail Merge using Excel VBA

I assumed that when I changed .MainDocumentType = wdCatalog that it would suppress the page breaks.

Any help is much appreciated.

Mark Nielsen
  • 991
  • 2
  • 10
  • 28

1 Answers1

0

You can try removing the maindocumenttype=wdCatalog and save the main word document as directory (by manually selecting it). Then run the macro, it will append without the page breaks.

double-beep
  • 5,031
  • 17
  • 33
  • 41
Carr
  • 1