|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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 |
#2
|
||||
|
||||
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 |
#3
|
|||
|
|||
Quote:
let me know if that doesnt answer your question. |
#4
|
||||
|
||||
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] |
#5
|
|||
|
|||
Quote:
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! |
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 |
Macro (debugging) | JACKsparrow | Word VBA | 1 | 03-09-2016 02:47 PM |
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 |