Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Merge two documents, or insert pages from another Word document

Status
Not open for further replies.

christer99

IS-IT--Management
Dec 3, 2001
247
I need to insert pages 3-5 from another Word document into the active Word document? I have tried use streamread but it seems to be working only with the files and not (large) Word documents.
 
Open the other file.
make a range of the pages - like so:

Code:
Dim r As Range
    Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:="3"
    ActiveDocument.Bookmarks.Add Name:="temp1", Range:=Selection.Range
    Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:="6"
    
    Set r = ActiveDocument.Range(Start:=ActiveDocument.Bookmarks("temp1").Range.Start, _
        End:=ActiveDocument.Bookmarks("\page").Range.End)

then you can copy that range text anywhere you want.


Gerry
 
I am getting errors: Name 'selection' is not declared, name 'wdGoToPage is not declared, name 'Active.Document" is not declared... I realize that this probably a beginner question and I am missing an import statement or a reference in Visual Basic 2003. I have the following imports:

Imports Word = Microsoft.Office.Interop.Word
Imports System
Imports System.IO
Imports System.Text
 
Huh?

Run this by again. You have a Word document. You want to select certain pages and insert them into another Word document.

What "imports" areyou talking about?

"Imports Word?
"Imports System?"

Could you post some code so we can see what you are actually doing?



Gerry
 
I fixed the problem, but now I have another (related) problem when I paste the copied information into the destination source document, I have problem detecting if I need a pagebreak or not (before and after the pasted document). I have been using oRng5.Information(Word.WdInformation.wdVerticalPositionRelativeToPage) but not sure if it actually working. Right now I have it so it is by defaultinserts a pagebreak before and after, however it seems if in some situations I get an extra page break, which I think is happening when I don't really need the page break after I have pated the copied document. How can I more effectively detect if I need a pagebreak and what is the proper code to use?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top