Link to home
Start Free TrialLog in
Avatar of Bobeo
Bobeo

asked on

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

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
Avatar of tinawin
tinawin
Flag of United States of America image

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?
Avatar of Bobeo
Bobeo

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of tinawin
tinawin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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

Avatar of Bobeo

ASKER

Sorry! Been away on holiday.

Tinawin, your answer nailed it for me! Cheers!