At this point I would look to version incompatibility at the document level. I am guessing we're dealing with AutoCad? here, and is it possible that the version of AutoCad used to create the document in which this program fails is different from the version of AutoCad that you normally use, or the version that your program is expecting. It doesn't fail in other documents because different version of AutoCad are not in play.
For example, it may be that the program is expecting a LineObj as defined in AutoCad 2005, but the document was created using AutoCad 2004 so the definition of the LineObj object is different. That could result in a type mismatch error.
This could be caused by an early binding to the LineObj type (dim LineObj as AcadLine) but a late binding (not dimensioned) to the ThisDrawing object resulting in two different AutoCad object definitions.
Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein