Solved

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

Posted on 2009-04-04
5
810 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

I'm writing to share my clumsy experience in using this elegant tool so you can avoid every stupid mistake I made. (I leave it to the authorities to decide if this deserves a place in the Knowledge archives.)  Now that I am on the other side of my l…
Preface: When I started this series, I used the term CommandBars because that is the Office Object class that it discusses. Unfortunately, when Microsoft introduced Office 2007, they replaced the standard Commandbar menus with "The Ribbon" and rem…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now