Select to view content in your preferred language

VBA question

426
1
06-11-2010 01:18 PM
LoringTupper
Deactivated User
I know, VBA is history, but some of use are still using it on 9.2.
My question is: how do you load an SDE annotation layer using VBA code? We're now using SDE 9 and the way SDE stores annotation appears to be different than when we were using older version of SDE. My old code, that worked prior to going to SDE 9n was as follows:

            Set pFeatureClass = pFeatureWorkspace.OpenFeatureClass("CALGIS.CNTST_LANDUSE_1P2007_LL")
            Set pFeatureLayer = New CoverageAnnotationLayer
 
            pFeatureLayer.Name = "Landuse Annotation Leadlines - 1P2007" 'set Layername
            pFeatureLayer.MinimumScale = 4000
            pFeatureLayer.ShowTips = True
   
            pMap.AddLayer pFeatureLayer   'Add Layer to Map
            pMxDoc.ActiveView.ContentsChanged

I get and error message indicating that an "Object Variable or With Block not set", how would I change the code to work with the new SDE annotation? What ArcObject should I now be using?
0 Kudos
1 Reply
RuchiraWelikala
Regular Contributor
I know, VBA is history, but some of use are still using it on 9.2.
My question is: how do you load an SDE annotation layer using VBA code? We're now using SDE 9 and the way SDE stores annotation appears to be different than when we were using older version of SDE. My old code, that worked prior to going to SDE 9n was as follows:

            Set pFeatureClass = pFeatureWorkspace.OpenFeatureClass("CALGIS.CNTST_LANDUSE_1P2007_LL")
            Set pFeatureLayer = New CoverageAnnotationLayer
 
            pFeatureLayer.Name = "Landuse Annotation Leadlines - 1P2007" 'set Layername
            pFeatureLayer.MinimumScale = 4000
            pFeatureLayer.ShowTips = True
   
            pMap.AddLayer pFeatureLayer   'Add Layer to Map
            pMxDoc.ActiveView.ContentsChanged

I get and error message indicating that an "Object Variable or With Block not set", how would I change the code to work with the new SDE annotation? What ArcObject should I now be using?


Try setting the DataSourceType of the FeatureLayer
Also see:
IFeatureLayer

pFeatureLayer.DataSourceType = "SDE Feature Class"
0 Kudos