Set pFeatureCursor = pFeatureclass.Update(pFilter, False) Set pFeature = pFeatureCursor.NextFeature While Not pFeature Is Nothing Dim pAnnoFeat As IAnnotationFeature Set pAnnoFeat = pFeature Dim pElement As IElement Set pElement = pAnnoFeat.Annotation Dim pTextElement As ITextElement Set pTextElement = pElement Dim pTextSym As ISimpleTextSymbol Set pTextSym = pTextElement.Symbol If Not pTextSym Is Nothing Then Dim pTextPath As ITextPath Set pTextPath = pTextSym.TextPath If TypeOf pTextPath Is IOverposterTextPath Then If TypeOf pElement.Geometry Is IPolyline Then Dim pPointCol As IPointCollection Set pPointCol = New Polyline Set pPointCol = pElement.Geometry ' Just keep start- and endpoint pPointCol.RemovePoints 1, pPointCol.PointCount - 2 '....... Replace textPath here ...... pFeatureCursor.UpdateFeature pFeature End If End If End If Set pFeature = pFeatureCursor.NextFeature Wend End If
Solved! Go to Solution.
Dim pFClass As IFeatureClass
Dim pEnumDS As IEnumDataset
Dim pDS As IDataset
Dim pWS As IWorkspace
Dim pWSE As IWorkspaceEdit
Dim pWSF As IWorkspaceFactory
Set pWSF = New AccessWorkspaceFactory
Set pWS = pWSF.OpenFromFile("C:\TestData\TestData.mdb", 0)
Set pWSE = pWS
Set pEnumDS = pWS.Datasets(esriDTAny)
Set pDS = pEnumDS.Next
Do Until pDS Is Nothing
If pDS.Name = "TestLayer1" Then
Set pFClass = pDS
Exit Do
End If
Set pDS = pEnumDS.Next
Loop
If Not pFClass Is Nothing Then
pWSE.StartEditing False
pWSE.StartEditOperation
Dim pFCur As IFeatureCursor
Dim pFeat As IFeature
Set pFCur = pFClass.Search(Nothing, False)
Set pFeat = pFCur.NextFeature
Do Until pFeat Is Nothing
''Do something with feature....
Set pFeat = pFCur.NextFeature
Loop
pWSE.StopEditOperation
pWSE.StopEditing True
End If
Thanks Jeff, that's the way: start an edit session.'*** edit session running *** If TypeOf pElement.Geometry Is IPolyline Then Dim pPointCol As IPointCollection Set pPointCol = New Polyline Set pPointCol = pElement.Geometry 'Replace textPath here ...... ' Just keep start- and endpoint Dim pNewPolyline As IPolyline Set pNewPolyline = New Polyline pNewPolyline.fromPoint = pPointCol.Point(0) pNewPolyline.toPoint = pPointCol.Point(pPointCol.PointCount - 1) pElement.Geometry = pNewPolyline pAnnoFeat.Annotation = pElement pFeatureCursor.UpdateFeature pFeature End If
One more question: is it possible to start an edit session programatically without having the involved featureclass loaded in the table of contents?