Results 1 to 4 of 4

Thread: Keep the formatting...

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2000
    Posts
    21

    Question

    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.

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Jun 2000
    Posts
    21

    Smile

    Forget it, I've done it in a different way.

  3. #3
    Lively Member
    Join Date
    May 2000
    Location
    Norway
    Posts
    112
    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.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Jun 2000
    Posts
    21

    Wink

    Thanks again, it's the second time you help me today. Thank u, I really appreciate.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width