-
Hi,
I'm going deeper into the VBA programming, I'm trying to make a program for Word. A part of the code goes like this (thanks to RealisticGraphics):
...
Set NewDoc = Word.Documents.Add
NewDoc.Content = Doc1.Content & Doc2.Content
Set NewDoc = Nothing
...
Everything (almost) works, but my problem is that in the new word document everything has changed from Doc1 and Doc2 (the character font, the titles of parts...). Is there a way to add two (or more) word documents in a new one while keeping the formatting ?
Thanks.
-
Forget it, I've done it in a different way.
-
This code should do it:
Code:
Dim Doc1 As Document
Dim Doc2 As Document
Dim NewDoc As Document
Documents.Open "c:\tmpp\asdasdassa.doc"
Set Doc1 = ActiveDocument
Documents.Open "c:\tmpp\qwerty.doc"
Set Doc2 = ActiveDocument
Set NewDoc = Documents.Add
NewDoc.Range = Doc1.Range & Doc2.Range
Doc1.Close
Doc2.Close
Content is Text-only, while Range is with formatting.
-
Thanks again, it's the second time you help me today. Thank u, I really appreciate.