View Single Post
 
Old 06-10-2020, 09:24 AM
Pramod Pramod is offline Windows 10 Office 2016
Novice
 
Join Date: Jun 2020
Posts: 1
Pramod is on a distinguished road
Default How to merge multiple header into one word file

I need code for Merge multiple header into one word file. Help me for the same.
I have mentioned the below code is for merge multiple word file into one.
Code:
Sub MergeMultiDocsIntoOne()
  Dim dlgFile As FileDialog
  Dim nTotalFiles As Integer
  Dim nEachSelectedFile As Integer
Set dlgFile = Application.FileDialog(msoFileDialogFilePicker)
 
  With dlgFile
    .AllowMultiSelect = True
    If .Show <> -1 Then
      Exit Sub
    Else
      nTotalFiles = .SelectedItems.Count
    End If
  End With
 
  For nEachSelectedFile = 1 To nTotalFiles
    Selection.InsertFile dlgFile.SelectedItems.Item(nEachSelectedFile)
    If nEachSelectedFile < nTotalFiles Then
      Selection.InsertBreak Type:=wdPageBreak
    Else
      If nEachSelectedFile = nTotalFiles Then
        Exit Sub
      End If
    End If
  Next nEachSelectedFile
End Sub

Last edited by macropod; 06-10-2020 at 03:43 PM. Reason: Added code tags
Reply With Quote