Macro to merge 2 documents

K

kimchi

Hi all,
I was asked to merge 2 documents (doc1=draft; doc2=final) into one document
(doc3) with the both the draft and final documents in it. The 2 docs must be
merged in such a way that, for example page 1 of doc1 is on the left hand
side of the page and page 1 of doc2 is on the right hand side of the page.
This will allow the reviewer to immediately see the previous version with
opening a separate document.

I understand that this can be easily solved by printing doc1 and doc2
separately and comparing them side by side but that’s another story.

Is there anyone who had a similar situation and had done a macro to solve
the problem? Can this be solved without coding?

Appreciate your help on this.

Thanks in advance!
kimchi
 
D

Doug Robbins

How about using the compare facility?

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
K

kimchi

Hi Doug,

Thanks for your response but this not really solve the problem. Compare will
merge the document into one which is true but will not produce the effect of
having the page 1 of doc1 is on the left hand side of the page and page 1 of
doc2 is on the right hand side of the page when printed.

Kimchi
 
D

Doug Robbins

I am not sure in what version of Word it was introduced, but in 2003, you
can compare two documents side by side.

The following untested macro should, when run with one of the documents
open, display the File Open dialog to select the second document, and then
should create a third document in which the pages alternate. If you then
print that document with 2 pages per sheet, you should get what you want:

Dim A As Document, B As Document, C As Document, Apage As Range, Bpage As
Range
Dim Pages As Long, i As Long
Set A = ActiveDocument
With Dialogs(wdDialogFileOpen)
.Show
End With
Set B = ActiveDocument
Set C = Documents.Add
A.Activate
A.Range.Select
Pages = Selection.Information(wdActiveEndPageNumber)
Selection.Collapse wdCollapseStart
For i = 1 To Pages
A.Activate
Selection.HomeKey wdStory
Set Apage = A.Bookmarks("\page").Range
C.Range.InsertAfter Apage
Apage.Delete
B.Activate
Selection.HomeKey wdStory
Set Bpage = B.Bookmarks("\page").Range
C.Range.InsertAfter Bpage
Bpage.Delete
Next i


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
M

myssine

Hi Doug,

I tried your macro because I was having the same problem as Kimchi. I am
using MS Office 2003 and I got a syntax error in the following code:

Dim A As Document, B As Document, C As Document, Apage As Range, Bpage As

Can you offer any advice?

Thanks,
Myssine
 
M

myssine

I figured out how to fix the syntax error, and the macro works. It creates a
new document using alternating pages from both documents. However, I need to
copy over my headers and footers into the document as well. (They are
different in both documents, and I have multiple sections.) Does anyone have
any ideas?

Thanks,
Myssine
 
D

Doug Robbins

Use Different Odd and Even headers/footers, inserting the relevant
header/footer information from the original documents.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top