cannot read a word.doc with more than 50 or 60 pages....while reading a word document(110 pages) the code read up to 50 pages...and then it rises an exception "COMException..... reading an item which s not in the collection"....but if i split up the word.doc in to two or three documents, the code works fine.....need help in this....


this the code which i have used..

Dim MyApp As Word.Application
Dim MyDoc As Word.Document
Dim ans As String
Dim anstr As String
Dim i As Integer
Dim k As Integer
Dim d As Integer
Dim j As Integer
Dim count As Integer
Dim check As Object
MyApp = CreateObject("Word.Application")
MyDoc = MyApp.Documents.Open("d:\\srd3.doc")
Dim oFile2 As System.IO.File
Dim oWrite As System.IO.StreamWriter
oWrite = oFile2.CreateText("D:\sample2.txt")

count = MyDoc.Tables.Count
For i = 1 To count
For k = 1 To MyDoc.Tables.Item(i).Columns.Count

If (IsNothing(MyDoc.Tables.Item(i).Rows(1).Cells(k)) = False) Then


If(MyDoc.Tables.Item(i).Rows(1).Cells(k).Range.Text.Contains("Data Type")) Then


MyDoc.Tables.Item(i).Rows(1).Cells(k).Range.Text.Remove(anstr.Length - 1, 1)

d = k
For j = 2 To MyDoc.Tables.Item(i).Rows.Count
oWrite.Write(MyDoc.Tables.Item(i).Rows(j).Cells(d).Range.Text)
oWrite.Write(MyDoc.Tables.Item(i).Cell(j, 1).Range.Text)
oWrite.WriteLine(d)
Next j

End If
End If

Next k




Next i
MyDoc.Close()
oWrite.Close()