Click here to Skip to main content
16,012,508 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi , here in the below code i had merged the multiple document files into a single file ,now i need to display the filename in between the files that are merged,

if "a.doc", "b.doc" are two files that are merged now i need the output as
a
------
a
b
----
b
this is the merged output

VB
Try
            ''INITIALISING THE OBJECTS, STRING AND INTEGER''
            Dim arraylist(100) As String
            Dim oFals As Object = False
            Dim oTru As Object = True
            Dim obj2 As Object = WdSaveFormat.wdFormatDocument
            Dim missing As Object = System.Reflection.Missing.Value
            object1 = TextBox1.Text & "\MERGED DOCUMENT"
            Dim i As Integer
            Dim formt As Object = WdOpenFormat.wdOpenFormatDocument
            Dim obj As Object
            Dim wat1 As Object = word.WdGoToItem.wdGoToLine
            Dim wich As Object = word.WdGoToDirection.wdGoToLast
            Dim wat As Object = word.WdUnits.wdStory
            Dim moov As Object = word.WdMovementType.wdMove
            Dim str As Integer = 1
            objapp = CreateObject("word.Application")
            objapp.Visible = False
            objdoc = objapp.Documents.Add
            objdoc.SaveAs(object1, obj2)
            ''LOOPING THE LISTBOX TIEMS TO A ARRAYLIST ''
            For i = 0 To ListBox2.Items.Count - 1
                arraylist(i) = ListBox2.Items(i)
                obj = arraylist(i)
                ''OPENING A DOCUMENT IN THE ARRAY LIST(LISTBOX ITEMS)''
                objdoc = objapp.Documents.Open(obj, missing, oFals, oTru) ', "", "", oFals, "", "", formt, "", "", "", "", "", "")
                objapp.Selection.WholeStory()
                objapp.Selection.Copy()
                objdoc.Close()
                '' OPENING A NEW DOCUMENT ''
                objdoc = objapp.Documents.Open(object1, missing, oFals, oTru) ', "", "", oFals, "", "", formt, "", "", "", "", "", "")
                objapp.Selection.EndKey(wat, moov)
                ''INSERTING TAG TO THE START OF THE DOCUMENT''
                Dim s1 As String = ""
                objapp.Selection.TypeParagraph()
                objapp.Selection.TypeText(s1)
                objapp.Selection.TypeParagraph()
                objapp.Selection.Paste()
                ''INSERTING TAG TO THE END OF THE DOCUMENT''
                Dim s2 As String = ""
                objapp.Selection.TypeText(s2)
                objapp.Selection.TypeParagraph()
                str = str + 1
                objdoc.Save()
                objdoc.Close()
            Next i
            objapp.Quit()
        Catch ex As Exception
            MessageBox.Show("SOME DOCUMENTS ARE USED BY ANOTHER PERSON 'OR' OUTPUT FILE ALREADY EXISTS(MERGED DOCUMENT)")
        End Try
    End Sub
Posted
Comments
Sergey Alexandrovich Kryukov 18-Nov-11 14:33pm    
Not a question. Why is this a problem?
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900