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.
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
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?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.