Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 11-28-2017, 08:27 AM
vincenzo345 vincenzo345 is offline Help debugging a Macro that merges individual word docs into one document Windows 7 64bit Help debugging a Macro that merges individual word docs into one document Office 2016
Novice
Help debugging a Macro that merges individual word docs into one document
 
Join Date: Aug 2017
Posts: 13
vincenzo345 is on a distinguished road
Default Help debugging a Macro that merges individual word docs into one document

So, I have this macro which sucessfully merges multiple word documents in a directory into one word doc. It works great but has a few issues.



Issue 1

The documents im merging vary in size. Some are letter and others are legal size. The page sizes dont transfer exactly as they should into the merged document.

Issue 2

There appear to be formatting issues, mainly with fonts and im not sure how to go about fixing this. there is one {INCLUDETEXT ""} field that contains a table and the font in the table always defaults to Calibri size 11.

Im at a loss on how to resolve these issues. So, any help is greatly appreciated.

Code:
 
 
Sub MergeDocsInFolder()
    Dim rng As Range
    Dim MainDoc As Document
    Dim strFile As String, strFolder As String
    With Application.FileDialog(msoFileDialogFolderPicker)
        .Title = "Pick folder"
        .AllowMultiSelect = False
        If .Show Then
            strFolder = .SelectedItems(1) & Application.PathSeparator
        Else
            Exit Sub
        End If
    End With
    Set MainDoc = Documents.Add
    strFile = Dir$(strFolder & "*.docx") ' can change to .docx
    Count = 0
    Do Until strFile = ""
        Count = Count + 1
        Set rng = MainDoc.Range
        With rng
            .Collapse wdCollapseEnd
            If Count > 1 Then
                .InsertBreak wdSectionBreakNextPage
                .End = MainDoc.Range.End
                .Collapse wdCollapseEnd
            End If
            .InsertFile strFolder & strFile
        End With
        strFile = Dir$()
    Loop
    MsgBox ("Files are merged")
lbl_Exit:
    Exit Sub
End Sub
Reply With Quote
 

Tags
documents, individual, merge



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro for printing 2 copies each on NCR paper for many different word docs Marq Word VBA 9 05-22-2017 08:31 PM
Help debugging a Macro that merges individual word docs into one document Macro (debugging) JACKsparrow Word VBA 1 03-09-2016 02:47 PM
Help debugging a Macro that merges individual word docs into one document Word 2010 New maros - debugging needed MacroMess Word VBA 6 06-05-2015 09:48 AM
On tracked changes - Word merges multiple authors into one "author" when the document is sent to me becklai Word 1 08-13-2014 08:57 AM
Macro to export document sections to individual txt files? MJMR999 Excel Programming 0 02-18-2010 12:49 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:37 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft