Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

it's my first project using ArcObject, i create this interface : http://i118.photobucket.com/albums/o104/b_sara/Cap2-1.png

i did programme the button "Parcourir" ( browse ) using a commonDialog, it get just the files "*.dbf"


Private Sub CmdPrc_Click() 
On Error GoTo Annuler 
With CommonDialog1 
    .DialogTitle = "Choisissez une Table"  
    .CancelError = True    
    .Filter = "Tous (*.dbf)|*.dbf"   
    .InitDir = "C:\" 
Text1.Text = .fileName


  If Text1.Text = "" Then   
    Label1.Caption = "Vous n'avez sélectionné aucun fichier."   
    Label1.Caption = ""
  End If 
End With
End Sub

the combobox also works good, but they take there value manually, this is the code :


Private Sub UserForm_Initialize()

With CmboX    
    .AddItem "OID"   
    .AddItem "PT"    
    .AddItem "PP"    
    .AddItem "PI"    
    .AddItem "BPLB"    
    .AddItem "BPLL"    
    .AddItem "RP"    
    .AddItem "CO2B"    
    .AddItem "CO2L"    
    .AddItem "MGOB"    
    .AddItem "MGOL"    
    .AddItem "X"    
    .AddItem "Y"    
End With

With CmboY    
    .AddItem "OID"    
    .AddItem "PT"    
    .AddItem "PP"    
    .AddItem "PI"    
    .AddItem "BPLB"    
    .AddItem "BPLL"    
    .AddItem "RP"    
    .AddItem "CO2B"    
    .AddItem "CO2L"    
    .AddItem "MGOB"    
    .AddItem "MGOL"    
    .AddItem "X"    
    .AddItem "Y"    
End With
CmboX.ListIndex = 11
CmboY.ListIndex = 12
End Sub

now i'm sticked at "Ok" button, and Edit button i don't know how to fix it,

the Button "Ok" should :

  • Open the Table "*.dbf" , then take the coordinate X and Y, and convert it to a shapefile, then open all the data with there (X, Y) in ArcMAP

the Button "Edit" should open that window to define a projection and a coordinate system :

that you can get it by adding a table -> click right -> Display XY Data -> click button "Edit" http://i118.photobucket.com/albums/o104/b_sara/Cap3.png

i need to programme that, that's the point of my training end of study

I need help, please if anyone could help me.

share|improve this question

2 Answers 2

You can try using the built-in Add XY Data tool.
GUID: {55425B75-2CE4-4909-B40A-CFE50FAD1896} (esriLocationUI.AddXYDataCommand)

Refer the following SE discussion on the same issue.


Open the XYZ data as a table, the same as opening any other table. Once you've done that, create a spatial reference for the data. After that, the attached code example should handle the rest.

Public Sub AddXYEventLayer()

On Error GoTo EH

Dim pDoc As IMxDocument
Dim pMap As IMap
Set pDoc = ThisDocument
Set pMap = pDoc.FocusMap

//Get the table named XYSample.txt
Dim pStTabCol As IStandaloneTableCollection
Dim pStandaloneTable As IStandaloneTable
Dim intCount As Integer
Dim pTable As ITable
Set pStTabCol = pMap

For intCount = 0 To pStTabCol.StandaloneTableCount - 1
Set pStandaloneTable = pStTabCol.StandaloneTable(intCount)
If pStandaloneTable.Name = "XYSample.txt" Then
Set pTable = pStandaloneTable.Table
Exit For
End If

If pTable Is Nothing Then
  MsgBox "The table was not found"
  Exit Sub
End If

//Get the table name object
Dim pDataSet As IDataset
Dim pTableName As IName
Set pDataSet = pTable
Set pTableName = pDataSet.FullName

// Specify the X and Y fields
Dim pXYEvent2FieldsProperties As IXYEvent2FieldsProperties
Set pXYEvent2FieldsProperties = New XYEvent2FieldsProperties
With pXYEvent2FieldsProperties
  .XFieldName = "x"
  .YFieldName = "y"
  .ZFieldName = ""
End With

// Specify the projection
Dim pSpatialReferenceFactory As ISpatialReferenceFactory
Dim pProjectedCoordinateSystem As IProjectedCoordinateSystem
Set pSpatialReferenceFactory = New SpatialReferenceEnvironment
Set pProjectedCoordinateSystem = pSpatialReferenceFactory.CreateProjectedCoordinateSystem(esriSRProjCS_NAD1983UTM_11N)

// Create the XY name object and set it's properties
Dim pXYEventSourceName As IXYEventSourceName
Dim pXYName As IName
Dim pXYEventSource As IXYEventSource  

Set pXYEventSourceName = New XYEventSourceName

With pXYEventSourceName
  Set .EventProperties = pXYEvent2FieldsProperties
  Set .SpatialReference = pProjectedCoordinateSystem
  Set .EventTableName = pTableName
End With
Set pXYName = pXYEventSourceName
Set pXYEventSource = pXYName.Open

// Create a new Map Layer
Dim pFlayer As IFeatureLayer
Set pFlayer = New FeatureLayer
Set pFlayer.FeatureClass = pXYEventSource
pFlayer.Name = "Sample XY Event layer"

//Add the layer extension (this is done so that when you edit
//the layer's Source properties and click the Set Data Source
//button, the Add XY Events Dialog appears)

Dim pLayerExt As ILayerExtensions
Dim pRESPageExt As New XYDataSourcePageExtension
Set pLayerExt = pFlayer
pLayerExt.AddExtension pRESPageExt

pMap.AddLayer pFlayer
pDoc.ActivatedView.PartialRefresh esriViewGeography, Nothing, Nothing

Exit Sub

MsgBox Err.Number & "  " & Err.Description

End Sub

To convertto shapefile, refer this URL


share|improve this answer

Another option for using less code would be to use the geoprocessing tools in model builder and export out the model to either VBScript, JScript, or Python script to tie in with your interface (see VBScript example below). You could also do this using ArcPy if you are using ArcGIS 10.

Dim gp as object

' Create the Geoprocessor object
set gp = CreateObject("esriGeoprocessing.GPDispatch.1")

' Load required toolboxes...
gp.AddToolbox "C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Conversion Tools.tbx"
gp.AddToolbox "C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Data Management Tools.tbx"

' Local variables...
Dim MyTable_dbf as string = "C:\Temp\MyTable.dbf"
Dim MyTable_Layer as string = "MyTable_Layer"
Dim Temp as string = "C:\Temp"
Dim Temp__2_ as string = "C:\Temp"
Dim MyTable_Layer_shp__3_ as string = "C:\Temp\MyTable_Layer.shp"
Dim MyTable_Layer_shp as string = "C:\Temp\MyTable_Layer.shp"

' Process: Make XY Event Layer...
gp.MakeXYEventLayer_management MyTable_dbf, "X", "Y", MyTable_Layer, ""

' Process: Feature Class To Shapefile (multiple)...
gp.FeatureClassToShapefile_conversion "MyTable_Layer", Temp__2_

' Process: Define Projection...
gp.DefineProjection_management MyTable_Layer_shp, "GEOGCS['GCS_North_American_1983_HARN',DATUM['D_North_American_1983_HARN',SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]]"
share|improve this answer
This is a good idea, but it does not work for creating a UI for the purpose of completing such tasks, which is what I think the OP wants. –  Nathanus May 23 '11 at 12:20
@Nathanus, I believe you can assign a variable to a UI control (e.g. textbox), which could then populate the VBS input and output parameters/variables. –  artwork21 May 23 '11 at 14:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.