Append two documents to one, how

S

Stan Brown

I've got a series of exams and solution sets. When I first made them
up, it seemed easy to have the exam and solutions as separate
documents; but for archiving I think I'd rather have the solutions
and exam in the same document (with an "odd page" section break
between them).

How do I append the solutions document to the exam document without
screwing up the formatting of either one? I know that I'll have to
fix the "page N of NN" in the headers to reference the number of
pages within section, but is there anything else to watch out for?

(Seems to me there was a reference in the group to a document about
this. I've just spent some time at
<http://word.mvps.org/Search/index.htm> but searches for "join
documents" and "append documents" didn't turn up anything.)
 
D

Doug Robbins

Here's a macro that I created for another poster who wanted to create a
document by combining alternate pages from two other documents. It might do
what you want:

Dim sourcea As Document, sourceb As Document, target As Document, Pages
As Integer, Counter As Integer, targetrange As Range 'targetrange added

Dim evenpage As Range

Set sourcea = Documents.Open(FileName:="...")

sourcea.Repaginate

Pages = ActiveDocument.BuiltInDocumentProperties(wdPropertyPages)

MsgBox Pages

Set sourceb = Documents.Open(FileName:="...")

Set target = Documents.Add

target.PageSetup.LeftMargin = sourcea.PageSetup.LeftMargin

target.PageSetup.RightMargin = sourcea.PageSetup.RightMargin

target.PageSetup.TopMargin = sourcea.PageSetup.TopMargin

target.PageSetup.BottomMargin = sourcea.PageSetup.BottomMargin

target.AcceptAllRevisions

Counter = 0

While Counter < Pages

sourcea.Activate

ActiveDocument.Bookmarks("\page").Range.Copy

Set targetrange = target.Range

targetrange.Start = targetrange.End

targetrange.Paste

ActiveDocument.Bookmarks("\page").Range.Cut

sourceb.Activate 'Assumed to be the document containing the even
pages

Selection.EndKey Unit:=wdStory 'Line of code added to start from the
end of the document

ActiveDocument.Bookmarks("\page").Range.Copy

Set targetrange = target.Range

targetrange.Start = targetrange.End

targetrange.Paste

targetrange.Start = targetrange.End

targetrange.InsertBreak Type:=wdPageBreak

Set evenpage = ActiveDocument.Bookmarks("\page").Range

evenpage.Start = evenpage.Start - 1

evenpage.Delete

Counter = Counter + 1

Wend

sourcea.Close wdDoNotSaveChanges

sourceb.Close wdDoNotSaveChanges

--
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
 
S

Stan Brown

S

Stan Brown

Here's a macro that I created for another poster who wanted to create a
document by combining alternate pages from two other documents. It might do
what you want:

Thanks for posting, Doug. This would actually be pretty slick if the
solutions were paginated the same as the exam questions, but
unfortunately they're not.

What I'm trying to do is something less ambitions: take document B
and put it at the end of document A, then save it as C so that if I
right-click on document C and select "Print" I'll get what I
formerly got from separately printing A and B separately.

--
Stan Brown, Oak Road Systems, Tompkins County, New York, USA
http://OakRoadSystems.com/
"What in heaven's name brought you to Casablanca?"
"My health. I came to Casablanca for the waters."
"The waters? What waters? We're in the desert."
 
D

Daiya Mitchell

This was one of the documents I looked at, but frankly I didn't
understand how it relates to my problem. Maybe I'm extra stupid
today,

Sections 2 and 4 should be directly relevant, depending on the method you
choose. But this also depends on what formatting you are trying to keep.
The page is basically about keeping different headers and footers and other
section formatting properties. If you want the Body Text style to have one
appearance in the Exam section and a different appearance in the Solutions
section, no can do.

Daiya
 
S

Stan Brown

Sections 2 and 4 should be directly relevant, depending on the method you
choose. But this also depends on what formatting you are trying to keep.
The page is basically about keeping different headers and footers and other
section formatting properties. If you want the Body Text style to have one
appearance in the Exam section and a different appearance in the Solutions
section, no can do.

That sounds like there's no easy way to append two documents
together without losing the styles of one of them. (Obviously I
could rename all the styles of one, but that's not exactly easy. :)

--
Stan Brown, Oak Road Systems, Tompkins County, New York, USA
http://OakRoadSystems.com/
"What in heaven's name brought you to Casablanca?"
"My health. I came to Casablanca for the waters."
"The waters? What waters? We're in the desert."
"I was misinformed."
 
D

Doug Robbins

All you have to do is use Ctrl+a in one document to select everything, then
Ctrl+c to copy it to the clipboard, then go to the end of the other document
and use Ctrl+v to paste the information from the clipboard into that
document. Save with a different name if you need to.

--
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
 
J

JoAnn Paules [MSFT MVP]

There is one way - turn them into .pdfs and combine them into one document.
I do that often.
 
D

Daiya Mitchell

If you want the Body Text style to have one
That sounds like there's no easy way to append two documents
together without losing the styles of one of them. (Obviously I
could rename all the styles of one, but that's not exactly easy. :)

Well, the point of using styles is consistency throughout a document, so no,
there's no "per section" setting for styles. Try JoAnn's PDF method.
 
J

JoAnn Paules [MSFT MVP]

My head is gonna explode. First Graham agreed with me, now you. Dang! I must
be better than I thought. :)
 
S

Stan Brown

All you have to do is use Ctrl+a in one document to select everything, then
Ctrl+c to copy it to the clipboard, then go to the end of the other document
and use Ctrl+v to paste the information from the clipboard into that
document.

That's if the two documents have identical styles and page setup
elements such as headers and footers.

--
Stan Brown, Oak Road Systems, Tompkins County, New York, USA
http://OakRoadSystems.com/
"What in heaven's name brought you to Casablanca?"
"My health. I came to Casablanca for the waters."
"The waters? What waters? We're in the desert."
"I was misinformed."
 
S

Stan Brown

There is one way - turn them into .pdfs

I thought I remembered reading here that Office doesn't export to
PDF natively?

--
Stan Brown, Oak Road Systems, Tompkins County, New York, USA
http://OakRoadSystems.com/
"What in heaven's name brought you to Casablanca?"
"My health. I came to Casablanca for the waters."
"The waters? What waters? We're in the desert."
"I was misinformed."
 
D

Daiya Mitchell

I thought I remembered reading here that Office doesn't export to
PDF natively?

It doesn't. Ton of freeware/shareware/cheaper alternatives to Acrobat out
there. I think JoAnn uses PrimoPDF, also seen CutePDF and PDF1995
mentioned. Check 'em out.

Though, on second thought it occurred to me that--can't you find the
efficiency you are looking for by selecting two documents in Windows
Explorer and right-clicking to Print, or somesuch? And do you really want
to risk the situation where you email students a sample exam and forget you
had been trying to be all efficient and give them the answers as well?

I'm not really sure having 1 doc is all that more efficient for archiving
than having 2. Putting two printouts in the same file folder is more
efficient, yes, but on the computer?

Daiya
 
J

JoAnn Paules [MSFT MVP]

Actually I use Acrobat Pro v7 but I also have PrimoPDF that I've tested so
that I could pass the information along to fellow guild editors.
 
S

Stan Brown

Though, on second thought it occurred to me that--can't you find the
efficiency you are looking for by selecting two documents in Windows
Explorer and right-clicking to Print, or somesuch?

The goal was to archive them on CD and make sure the exam and its
solutions never get separated.

Needless to say, since I recognized this problem I've been creating
them as a single documents from the get-go.
And do you really want
to risk the situation where you email students a sample exam and forget you
had been trying to be all efficient and give them the answers as well?

:)

That would be a concern, I agree. But I have sample exams on the
class Web pages, so I think I'm covered there.

--
Stan Brown, Oak Road Systems, Tompkins County, New York, USA
http://OakRoadSystems.com/
"What in heaven's name brought you to Casablanca?"
"My health. I came to Casablanca for the waters."
"The waters? What waters? We're in the desert."
"I was misinformed."
 
S

Stan Brown

It doesn't. Ton of freeware/shareware/cheaper alternatives to Acrobat out
there. I think JoAnn uses PrimoPDF, also seen CutePDF and PDF1995
mentioned. Check 'em out.

Thanks. (I saw JoAnn's follow-up to the effect that she actually
uses an Acrobat product but keeps PrimoPDF around to see how the
other half lives.<grin>)

I think PDF would be overkill for this particular project -- and
based on the comments I'm coming to the conclusion that doing much
of anything is overkill for this particular project -- but it's
worth adding to my toolbag for the long term.

--
Stan Brown, Oak Road Systems, Tompkins County, New York, USA
http://OakRoadSystems.com/
"What in heaven's name brought you to Casablanca?"
"My health. I came to Casablanca for the waters."
"The waters? What waters? We're in the desert."
"I was misinformed."
 
J

JoAnn Paules [MSFT MVP]

Hey now! I *am* the other half. ;-)

The copy of Acrobat I have was purchased by the organization I belong to. I
do the newsletter and website and it's very nice for getting our information
out to our members. If they hadn't agreed to the purchase, I'd be using
PrimoPDF.
 

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