Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21096

VB6 + Word - Merge 2 Word Documents and Preserve Formatting on Both

$
0
0
Hello Everyone.

I have a vb6 program that basically shells a program that sends faxes from the command line. Unfortunately, the program xmedius sendfax only accepts 1 attachment. What I need to do is dynamically create a coversheet and dynamically create another document (the body). I successfully create both documents and I successfully merge the 2 documents, however the formatting on the 2nd document is lost and just takes on the margins, etc of the coversheet/1st document. Below is the code. My question would be... How do I preserve the formatting of the 2nd document?

Code:

Public Function MergeDocumentsIntoSingleOne(ByVal sFirstFile As String, ByVal sSecondFile As String, ByRef wrdapp As Word.Application) As Boolean
    Dim docNew As Word.Document
   
    Set docNew = wrdapp.Documents.Open(sFirstFile)
       
    wrdapp.Selection.EndKey Unit:=wdStory
    wrdapp.Selection.InsertBreak Type:=wdPageBreak
    wrdapp.Selection.InsertFile FileName:=sSecondFile
       
    'save the document
    docNew.SaveAs "C:\NewFile.doc"
           
    Set docNew = Nothing
End Function

Thank you,

-HDIS_Jesse

Viewing all articles
Browse latest Browse all 21096

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>