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
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)