| Products: ArcView: VBA Platforms: WindowsMinimum ArcGIS Release: 9.0 |
How to use:
[VBA]
- Reference the following Assemblies: ESRI.ArcGIS.Carto, ESRI.ArcGIS.Display, ESRI.ArcGIS.Geometry
- Add the 'node' feature class of the ..\SampleMaps\Data\JoshuaTreeNP\roads coverage as a layer.
- Change the location of the coverage workspace to correspond to your ArcGIS installation.
- Run the procedure.
Public SubSetDataSource()DimpWorkspaceFactoryAsIWorkspaceFactoryDimpWorkspaceAsIWorkspaceDimpFWorkspaceAsIFeatureWorkspaceDimpNewFCAsIFeatureClassDimpOldFCAsIFeatureClassDimpFCContainerAsIFeatureClassContainer'Get FeatureClass to be set as datasourceSetpWorkspaceFactory =NewArcInfoWorkspaceFactorySetpWorkspace = pWorkspaceFactory.OpenFromFile("D:\ArcGIS\SampleMaps\Data\JoshuaTreeNP", 0)SetpFWorkspace = pWorkspaceSetpFCContainer = pFWorkspace.OpenFeatureDataset("roads")SetpNewFC = pFCContainer.ClassByName("arc")'Get current FeatureClass of first layerDimpMxDocAsIMxDocumentDimpMapAsIMapDimpActiveViewAsIActiveViewDimpMapAdmin2AsIMapAdmin2DimpFLayerAsIFeatureLayerSetpMxDoc = ThisDocumentSetpMap = pMxDoc.FocusMapSetpMapAdmin2 = pMapSetpActiveView = pMapSetpFLayer = pMap.Layer(0)SetpOldFC = pFLayer.FeatureClass'Change FeatureClass of layerSetpFLayer.FeatureClass = pNewFC pMapAdmin2.FireChangeFeatureClass pOldFC, pNewFC pActiveView.Refresh'Update and Refresh TOCDimpFDatasetAsIFeatureDatasetSetpFDataset = pFCContainer pFLayer.Name = pFDataset.Name & " " & pNewFC.AliasName pMxDoc.CurrentContentsView.Refresh 0End Sub
