Solved

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

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
This Micro Tutorial well show you how to find and replace special characters in Microsoft Word. This is similar to carriage returns to convert columns of values from Microsoft Excel into comma separated lists.

786 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