D
Damien
All,
I've written this code to combine two documents in code, but I don't really
like it.
I did try using the Range object, but as the letters have Word tables in, it
didn't seem to work. I need to capture all tables and formatting in the
document.
Does anyone have any better ideas or code?
Thanks
Damien
Private Function CombineDocuments(letter_object As Word.Document,
projection_object As Word.Document) As Word.Document
Dim Doc As Word.Document
Set Doc = Documents.Add(DocumentType:=wdNewBlankDocument)
'Copy letter
Windows(letter_object.Name & " (Read-Only)").Activate
With Selection
.WholeStory
.Copy
End With
'Paste in new document
Doc.Activate
With Doc.Range
.PasteAndFormat (wdPasteDefault)
Selection.EndKey Unit:=wdStory
End With
'Copy projection_object
Windows(projection_object.Name & " (Read-Only)").Activate
With Selection
.WholeStory
.Copy
End With
'Paste in new document
Doc.Activate
With Selection
.InsertBreak Type:=wdPageBreak
.PasteAndFormat (wdPasteDefault)
End With
Set CombineDocuments = Doc
End Function
I've written this code to combine two documents in code, but I don't really
like it.
I did try using the Range object, but as the letters have Word tables in, it
didn't seem to work. I need to capture all tables and formatting in the
document.
Does anyone have any better ideas or code?
Thanks
Damien
Private Function CombineDocuments(letter_object As Word.Document,
projection_object As Word.Document) As Word.Document
Dim Doc As Word.Document
Set Doc = Documents.Add(DocumentType:=wdNewBlankDocument)
'Copy letter
Windows(letter_object.Name & " (Read-Only)").Activate
With Selection
.WholeStory
.Copy
End With
'Paste in new document
Doc.Activate
With Doc.Range
.PasteAndFormat (wdPasteDefault)
Selection.EndKey Unit:=wdStory
End With
'Copy projection_object
Windows(projection_object.Name & " (Read-Only)").Activate
With Selection
.WholeStory
.Copy
End With
'Paste in new document
Doc.Activate
With Selection
.InsertBreak Type:=wdPageBreak
.PasteAndFormat (wdPasteDefault)
End With
Set CombineDocuments = Doc
End Function