Change of field order of shapefile attribute table in ArcMap 9.2

Discussion created by kjkim134 on Feb 4, 2011
Latest reply on Feb 18, 2011 by kjkim134
Withe the following macro, I could open an attribute table of pFeatureLayer that was just added but could not change the field order as I intended.  Actually, the field order did not change at all.  The macro did not show an error message, though.  Probably the macro could not access the opened attribute table?  Or, what could be wrong in the following VBA macro?  Please, can anybody help me out?



   ' Open the attribute table window.

    Dim pTableWindow As ITableWindow
    Set pTableWindow = New TableWindow
    Set pTableWindow.FeatureLayer = pFeatureLayer
    Set pTableWindow.Application = Application
    pTableWindow.TableSelectionAction = esriSelectFeatures
    pTableWindow.ShowAliasNamesInColumnHeadings = True
    pTableWindow.Show True
    ' Get the properties for this table window.

    Dim pTableProperties As ITableProperties
    Dim pEnumTableProperties As IEnumTableProperties
    Dim pTableProperty As ITableProperty
    Set pTableProperties = pMxDoc.TableProperties
    Set pEnumTableProperties = pTableProperties.IEnumTableProperties
    Set pTableProperty = pEnumTableProperties.Next

    ' Re-order the fields

    pTableProperty.FieldOrder = "OBJECT_ID, UFI, MF, NT, UNI, LAT, LONG"
    ' Freeze the first 4 fields on the left side of the attribute table

    pTableProperty.FrozenFields = 4
    Dim pTableControl As ITableControl
    Set pTableControl = pTableWindow.TableControl
    ' Refresh the active view.