Problem: Field aliases are wrong when using Dissolve method of IBasicGeoprocessor


When using the IBasicGeoprocessor Dissolve method and adding the result to the map the field aliases of the dissolve result (as seen in the field headings of the layer's attribute table) are incorrect.


Aliases are not correctly assigned when adding the dissolve output into ArcMap using VBA. Aliases are assigned correctly when using the Dissolve from the GeoProcessing Wizard. No field aliases will be assigned if you do not add the output to ArcMap programmatically.

Solution or Workaround

The workaround is to set the field aliases to be the same as the field names. To do this, append the following code to your VBA dissolve script. This should go right after you have added the dissolve output (pLayer) to the map (pMxDoc).


Set pLayer = New FeatureLayer
Set pLayer.FeatureClass = pOutputFC
pLayer.Name = pOutputFC.AliasName
pMxDoc.FocusMap.AddLayer pLayer

Dim pTFlds As ITableFields
Set pTFlds = pLayer
Dim pFldInfo As IFieldInfo
Dim i As Integer

For i = 0 To pTFlds.FieldCount - 1
Set pFldInfo = pTFlds.FieldInfo(i)
pFldInfo.Alias = pTFlds.Field(i).Name
Next i