Merge Word Documents As Pages Of A Single Document Using VB.NET

Discussion in 'ASP.NET' started by elizas, Apr 27, 2010.

  1. elizas

    elizas New Member

    Joined:
    Feb 9, 2010
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    Home Page:
    http://www.mindfiresolutions.com/
    Lets say we have a word template file and we need to populate the template for "n" number of records and display a single large word document , instead of "n" separate documents.

    So after creating the separate documents we need to merge them and create a single document with multiple pages.

    Hope this tip would add some value.Any suggestions are welcomed,
     
  2. mialuzzatto

    mialuzzatto New Member

    Joined:
    Aug 5, 2015
    Messages:
    122
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Work at https://www.idevelopersquare.com
    Location:
    Waltham, MA, USA
    Home Page:
    https://www.idevelopersquare.com
    Hello,

    Bit helpful.
     
  3. alia123

    alia123 New Member

    Joined:
    Jan 8, 2016
    Messages:
    65
    Likes Received:
    5
    Trophy Points:
    0
    Hey, try this code :
    Code:
       Imports RasterEdge.Imaging.Basic
         Imports RasterEdge.Imaging.Basic.Core
         Imports RasterEdge.Imaging.Basic.Codec
         Imports RasterEdge.Imaging.MSWordDocx
    
         Namespace RE__Test
         Public Partial Class Form1
         Inherits Form
         Public Sub New()
         InitializeComponent()
         End Sub
    
         Public Shared FolderName As String = "c:/"
    
         Private Sub button1_Click(sender As Object, e As EventArgs)
         Dim fileName1 As String = FolderName & "Sample1.docx"
         Dim fileName2 As String = FolderName & "Sample2.docx"
         Dim fileNameMerged As String = FolderName & "Merged.docx"
    
         Dim doc1 As REDocument = REFile.OpenDocumentFile(fileName1, New DOCXDecoder())
         'use DOCXDecoder open one word file
         Dim doc2 As REDocument = REFile.OpenDocumentFile(fileName2, New DOCXDecoder())
         'use DOCXDecoder open another word file
         Dim docMerged As BaseDocument = doc1.MergeDocument(doc2)
         'merge two word
         REFile.SaveDocumentFile(DirectCast(docMerged, REDocument), fileNameMerged, New DOCXEncoder())
         'save new word
         End Sub
    
         End Class
         End Namespace
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice