Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #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
  #2  
Old 11-28-2017, 03:29 PM
Guessed's Avatar
Guessed Guessed is offline Help debugging a Macro that merges individual word docs into one document Windows 10 Help debugging a Macro that merges individual word docs into one document Office 2013
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

What table style is applied to the problem table? Does your document have the font sizes defined in that table styles?
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #3  
Old 11-30-2017, 08:02 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

Quote:
Originally Posted by Guessed View Post
What table style is applied to the problem table? Does your document have the font sizes defined in that table styles?
Im not sure what you mean by table "style" its a 2 Row x 3 column table with the font in the table set to arial 8.

let me know if that doesnt answer your question.
Reply With Quote
  #4  
Old 11-30-2017, 01:53 PM
macropod's Avatar
macropod macropod 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 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

To see what've involved in combining documents with different page layouts, see my post of 1 Oct 2017 at: http://www.eileenslounge.com/viewtopic.php?f=26&t=27951, particularly the 'LayoutTransfer' sub there. On top of that, you have the content formatting issues you've already identified to deal with. They arise primarily because of Style conflicts, which will only be exacerbated if people have been overriding the Style definitions with direct formatting.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 12-01-2017, 11:25 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

Quote:
Originally Posted by macropod View Post
To see what've involved in combining documents with different page layouts, see my post of 1 Oct 2017 at: http://www.eileenslounge.com/viewtopic.php?f=26&t=27951, particularly the 'LayoutTransfer' sub there. On top of that, you have the content formatting issues you've already identified to deal with. They arise primarily because of Style conflicts, which will only be exacerbated if people have been overriding the Style definitions with direct formatting.
Dude. . . you're awesome. Just saying.

I'll look into the style conflicts. its not something I fully understand yet. However, If I have more questions about it I'll create a new post.

Thanks everyone!
Reply With Quote
Reply

Tags
documents, individual, merge

Thread Tools
Display Modes


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 01:23 AM.


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