Home arrow GIS Data & Resources arrow Scripts and Code arrow Visual Basic / VBA arrow ArcObjects VBA Example: Write Attributes Field Names To a Text File
ArcObjects VBA Example: Write Attributes Field Names To a Text File PDF Print E-mail

Written by AGRC Administrator,

This VBA script for ArcMap shows an simple example of how to write user defined attribute field names in a feature class to a text file.


Public Sub DumpAttributeFieldNames()
 Open "c:/temp/fields.txt" For Output As #1

 Dim pMxDoc As IMxDocument
 Dim pMap As IMap
 Dim pFLayer As IFeatureLayer
 Dim pFClass As IFeatureClass
 
 Set pMxDoc = ThisDocument
 Set pMap = pMxDoc.FocusMap
 
 'Get reference to layer in table of contents (0 is topmost layer)
 Set pFLayer = pMap.Layer(0)
 Set pFClass = pFLayer.FeatureClass
 
 Dim f As Integer
 
 
 For f = 0 To pFClass.Fields.FieldCount - 1
    If pFClass.Fields.Field(f).Editable And pFClass.Fields.Field(f).Name <> pFClass.ShapeFieldName Then
        Print #1, pFClass.Fields.Field(f).Name
    End If
 Next f

 Close #1

End Sub


Users' Comments  
 

No comment posted

Add your comment

01, Nov. 2007
Last Updated ( 01, Nov. 2007 )
 
< Prev   Next >

AGRC Contacts | UGIC Contacts

feed image feed image

Utah GIS Portal © 2009 AGRC

Optimized for