I am try to export field and X Y but I get the following error. Is it possible for someone to help me with this?
system.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type 'ESRI.ArcGIS.Geometry.IPoint'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{1B077915-38C5-11D0-92D2-00805F7C28B0}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
The Code:
Dim delimiter As String = ","
Dim aFileName As String
aFileName = "c:\log.txt"
Dim pPt As IPoint
FileOpen(1, aFileName, OpenMode.Output, OpenAccess.Default, OpenShare.Shared)
' Get first layer in map which is the annotation layer
Dim pMXDocument As IMxDocument
' pMXDocument = My.ArcMap.Document.ActiveView
pMXDocument = My.ArcMap.Document
Dim pMap As IMap
pMap = pMXDocument.FocusMap
Dim pLayer As ILayer
pLayer = pMap.Layer(0)
Dim pFeatureLayer As IFeatureLayer
pFeatureLayer = pLayer
' Create a cursor
Dim pFtrCsr As IFeatureCursor
pFtrCsr = pFeatureLayer.Search(Nothing, False)
' loop printing text string
Dim s As String
Dim pFtr As IFeature
pFtr = pFtrCsr.NextFeature
Do While Not pFtr Is Nothing
' On Error Resume Next
pPt = pFtr.Shape
s = CStr(pFtr.Value(pFtr.Fields.FindField("TEXTSTRING"))) + "," + CStr(pPt.X) + "," + CStr(pPt.Y)
' s = pFeature.Value(pFeature.Fields.FindField("TEXTSTRING"))
' Debug.Print(s)
WriteLine(1, s)
pFtr = pFtrCsr.NextFeature
Loop
FileClose(1)