Bonjour,
Dans son message, < Tom > écrivait :
In this message said:
Using Word 2002, using vba we would like to copy the text
from 1st open document, paste to 3rd document, then copy
the text from 2nd open document and paste after the 1st
documents text on 3rd document. The 3rd document is then
saved.
If this is possible guidance on code would be appreciated
Yes.
To make sure it goes smoothly, declare 3 document object
Dim Doc1 As Document
Dim Doc2 As Document
Dim Doc3 As Document
and 3 range object
Dim Range1 As Range
Dim Range2 As Range
Dim Range3 As Range
Then assign the documents to the Document variables
Set Doc1 = Application.Documents(1)
Set Doc2 = Application.Documents(2)
Set Doc3 = Application.Documents(3)
It is better to use Document names so s to avoid errors, like:
Set Doc3 = Application.Documents("Document3.doc")
Then go from there.
Define a range in Doc1.
e.g.:
With Doc1.Range
Set Range1 = Doc1.Range(.Paragraphs(1).Range.Start, _
.Paragraphs(3).Range.End).FormattedText
End With
If you want the full text:
Set Range1 = Doc1.Range.FormattedText
Finally,
Set Range3 = Doc3.Range
Range3.Collapse wdCollapseEnd
Range3.FormattedText = Range1
Range3.Collapse wdCollapseEnd
And repeat for Range2.
Using Document and Range objects you are 100% in control.
Try not to use the Selection object which can get really messy when going
form document to document...
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site:
http://www.word.mvps.org