Build Network Dataset using VBA (ArcGIS 9.3)

11-02-2011 07:15 AM
New Contributor
For every iteration, I update my cost field and subsequently build the network dataset to reflect those changes.
Following is the code I am using for building the network dataset.

Private Sub buildNetworkDataset()

    Dim pWorkspaceFactoryM As IWorkspaceFactory
    Dim pFeatureWorkspaceM As IFeatureWorkspace
    Set pWorkspaceFactoryM = New ShapefileWorkspaceFactory
    Set pFeatureWorkspaceM = pWorkspaceFactoryM.OpenFromFile("C:\data\", 0)
    Dim pWSExtMgr As IWorkspaceExtensionManager
    Dim pUID As New UID
    Dim pWSExt As IWorkspaceExtension
    Dim pDSCont As IDatasetContainer2
    Dim pND As INetworkDataset
    Dim pGeoDS As IGeoDataset
    Dim pNB As INetworkBuild
    Dim pReturnedExtent As IEnvelope
    Set pWSExtMgr = pFeatureWorkspaceM
    pUID.Value = "{4C1B151C-48C3-46C5-AB57-E6B941A1D00A}"
    Set pWSExt = pWSExtMgr.FindExtension(pUID)
    Set pDSCont = pWSExt
    Set pND = pDSCont.DatasetByName(esriDTNetworkDataset, "Network_ND")
    Set pGeoDS = pND
    Set pNB = pND
    Set pReturnedExtent = pNB.BuildNetwork(pGeoDS.Extent.Envelope)

End Sub 

But it encounters a run-time error '-2147220937 (80040237)': Automation Error at the very last line:

Set pReturnedExtent = pNB.BuildNetwork(pGeoDS.Extent.Envelope)

Now, I can't figure out what is wrong with the code. Can anybody help me on this?


0 Kudos
0 Replies