Solved

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

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Nice table. Huge mess. Maybe this was something you created way back before you figured out tabs or a document you received from someone else. Either way, using the spacebar to separate the columns resulted in a mess. Trying to convert text to t…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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 make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

832 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