Solved

Combining Word documents with different margins, headers and footers etc into 1 document

Posted on 2009-04-04
5
814 Views
Last Modified: 2013-11-05
Hi guys,

I'm having some trouble combining Word documents. I know there are a lot of solutions around for combining documents, but mine contain different margins, headers and footers and general page setups.

If anyone has any ideas as to how to combine lots of very differently formatted docs into 1 master document that'd be great!

Cheers,

Bob
0
Comment
Question by:Bobeo
  • 2
  • 2
5 Comments
 
LVL 1

Expert Comment

by:tinawin
ID: 24068537
Hey Bob,

What version of Word are you using. Do you know that Word uses section breaks so that margins, header and footer can be different in each section?
0
 
LVL 3

Author Comment

by:Bobeo
ID: 24068553
Hey Tinawin,

I personally am using 2007, but the process will be used by the public so it needs to work on anything from 2000 and above really.

I was aware of the section break method, but can't find a way to automate the process of taking the margins and headers from each file and applying them to the master one.
0
 
LVL 1

Accepted Solution

by:
tinawin earned 500 total points
ID: 24068732
Bobeo,

Before combining the files I change Word's view to outline, inserted the files, then change back to print layout view. Margins, Header and Footer didn't change. Below is the macro I recorded maybe this can help with the automation.

Sub insertMaster()
'
' insertMaster Macro
'
'
    ActiveWindow.ActivePane.View.Type = wdOutlineView
    If ActiveWindow.View = wdMasterView Then
        ActiveWindow.View = wdOutlineView
    Else
        ActiveWindow.View = wdMasterView
    End If
    Selection.Range.Subdocuments.AddFromFile Name:="Narrow Margins.docx", _
        ConfirmConversions:=False, ReadOnly:=False, PasswordDocument:="", _
        PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
        WritePasswordTemplate:=""
    Selection.Range.Subdocuments.AddFromFile Name:="t Life is wonderful.docx", _
         ConfirmConversions:=False, ReadOnly:=False, PasswordDocument:="", _
        PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
        WritePasswordTemplate:=""
    WordBasic.ViewPageFromOutline
0
 
LVL 4

Expert Comment

by:Xcone
ID: 24071851
You can also use the clipboard. It's not neat, but it works. Below is a macro which will use the clipboard to paste a second document below the first.
Public Sub MergeDocs(ByVal ATargetDocument As Document, ByVal ASoureDocument As Document)
  Dim r As Range
  
  Set r = ATargetDocument.Range
  r.Collapse wdCollapseEnd
  ATargetDocument.Sections.Add r, WdSectionStart.wdSectionNewPage
  
  ASoureDocument.Range.Copy
  
  Set r = ATargetDocument.Range
  r.Collapse wdCollapseEnd
  r.Paste
End Sub

Open in new window

0
 
LVL 3

Author Comment

by:Bobeo
ID: 24176622
Sorry! Been away on holiday.

Tinawin, your answer nailed it for me! Cheers!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A few years ago I was very much a beginner at VBA, and that very much remains the case today.  I'll do my best to explain things as I go in the hope that other beginners can follow.  If you just want to check out a tool that creates a Select Case fu…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question