<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Add DBF file to ArcMAP Table of Contents in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/add-dbf-file-to-arcmap-table-of-contents/m-p/551056#M14908</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes and it opened fine.&amp;nbsp; The SHP\FINAL directory contains not only a DBF but all the files for the complete shape file format.&amp;nbsp; When I am in ArcMAP and click the ADD button it will not display the dbf if it is part of a shape file (it will display the shp file extension).&amp;nbsp; So I copied just the DBF to anoth directory and added it fine.&amp;nbsp; I can add the DBF's that I created with my program, but I can't add them programmatically for some reason.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 18 Jun 2012 18:08:34 GMT</pubDate>
    <dc:creator>DanWolford</dc:creator>
    <dc:date>2012-06-18T18:08:34Z</dc:date>
    <item>
      <title>Add DBF file to ArcMAP Table of Contents</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/add-dbf-file-to-arcmap-table-of-contents/m-p/551054#M14906</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This is my second program using ArcObjects and I am having some technical difficulties.&amp;nbsp; I have another program I wrote that will allow you to select&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;tabular information from Excel and Save that to a Dbase *.dbf file where you can provide field attribute information.&amp;nbsp; This program will be an ArcMap&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Add-in that will run the previously mentioned program creating a DBF file.&amp;nbsp; This DBF file will then be added to open ArcMAP file and then be joined to&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;an existing SHP file.&amp;nbsp; I am running 64-bit Windows 7 Professional with Visual Studio Express 2008.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The full source code is in the attached zip file and contains the four routines discussed below.&amp;nbsp; I only included the AddDBFLayer in this posting.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The routines in the code below is mostly borrowed from ESRI Samples and are all basically just to add the DBF file to ArcMAP.&amp;nbsp; Each of these programs &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;have there own errors that are listed in the code.&amp;nbsp; I would not be surprised if I am not properly assigning the Map Application or the Map Document &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;variables.&amp;nbsp; Currently I have 4 main programs called when(OnClick) button is selected.&amp;nbsp; These 4 programs are just 4 different ways I have attempted to&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;solve my problem, and I am looking for one good one.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1.) AddDBF - This program gives no errors but does not add the DBF to the Table of Contents?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2.) AddDBFLayer&amp;nbsp; - This program Calls AddTable which calls OpenTable.&amp;nbsp; The error occurs when trying to open the table.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3.) AddShapefile -&amp;nbsp; Error occurs when trying to open the shapefile&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;4.) AddShapefile2 - Error occurs when trying to open the shapefile.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any and all help would be greatly appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dan&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;Imports ESRI.ArcGIS.CatalogUI Imports ESRI.ArcGIS.Framework Imports ESRI.ArcGIS.esriSystem Imports ESRI.ArcGIS.Desktop Imports ESRI.ArcGIS.ArcMapUI Imports ESRI.ArcGIS.DataSourcesFile Imports ESRI.ArcGIS.Geodatabase Imports ESRI.ArcGIS.Carto Imports ESRI.ArcGIS.Geometry Imports ESRI.ArcGIS.Display Imports System.IO Imports ESRI.ArcGIS.ADF Imports System.Drawing&amp;nbsp; Public Class btnXLStoDBF &amp;nbsp;&amp;nbsp;&amp;nbsp; Inherits ESRI.ArcGIS.Desktop.AddIns.Button &amp;nbsp;&amp;nbsp;&amp;nbsp; Private m_application As ESRI.ArcGIS.Framework.IApplication &amp;nbsp;&amp;nbsp;&amp;nbsp; Private mx_application As ESRI.ArcGIS.ArcMapUI.IMxApplication '*********************************************************************************************************************************************&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Protected Overrides Sub OnClick() &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '**EXECUTES THIS CODE WHEN BUTTON IS PRESSED IN ARCMAP &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Call AddDBF() &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Call AddDBFLayer() &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Call AddShapefile() &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Call AddShapefile2() &amp;nbsp;&amp;nbsp;&amp;nbsp; End Sub &amp;nbsp;&amp;nbsp;&amp;nbsp; Protected Overrides Sub OnUpdate() &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Enabled = My.ArcMap.Application IsNot Nothing &amp;nbsp;&amp;nbsp;&amp;nbsp; End Sub &amp;nbsp;&amp;nbsp;&amp;nbsp; Public Sub AddDBFLayer() &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Try &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Dim eApp As IMxApplication = My.ThisApplication &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Dim App As ESRI.ArcGIS.Framework.IApplication = My.ThisApplication &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pDoc As IMxDocument = My.ArcMap.Document &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pMap As IMap = pDoc.FocusMap &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Call AddTable(pMap, pDoc) &amp;nbsp;&amp;nbsp;&amp;nbsp; End Sub &amp;nbsp;&amp;nbsp;&amp;nbsp; Public Sub AddTable(ByVal map As IMap, ByVal mxDocument As IMxDocument) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'SOURCE OF THE FOLLOWING SUBROUTINES: ArcObjects SDK 10 MS .NET Framework: Concepts and Samples &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'ArcObjects Help for .NET developers\Developting with ArcGIS\Learning ArcObjects\Interacting with and configuring maps, layers, and graphics\ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Working with the Map\Performing basic map functions &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/Performing_basic_map_functions/000100000147000000/ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim tableCollection As ITableCollection = TryCast(map, ITableCollection) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim tablePathName As String = "C:\Users\dwolford\Documents\Visual Studio 2008\Projects\XLStoDBF\XLStoDBF\SHP\FINAL" &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim tableName As String = "RT010-61-880-FINAL.DBF" &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim table As ITable = OpenTable(tablePathName, tableName) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If (table Is Nothing) Then &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Return &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Else &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tableCollection.AddTable(table) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxDocument.UpdateContents() &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If &amp;nbsp;&amp;nbsp;&amp;nbsp; End Sub &amp;nbsp;&amp;nbsp;&amp;nbsp; Public Function OpenTable(ByVal pathName As String, ByVal tableName As String) As ITable &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Create the workspace name object. &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim workspaceName As IWorkspaceName = New WorkspaceNameClass() &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; workspaceName.PathName = pathName &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; workspaceName.WorkspaceFactoryProgID = "esriDataSourcesFile.shapefileworkspacefactory" &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Create the table name object. &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim dataSetName As IDatasetName = New TableNameClass() &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dataSetName.Name = tableName &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dataSetName.WorkspaceName = workspaceName &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Open the table. &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim Name As IName = TryCast(dataSetName, IName) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim table As ITable = TryCast(Name.Open(), ITable)&amp;nbsp; '&amp;lt;--ERROR HERE &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '&amp;nbsp;&amp;nbsp;&amp;nbsp; Error -2147220655: Exception from HRESULT: 0x80040351 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '&amp;nbsp;&amp;nbsp;&amp;nbsp; Systems.Collections.ListDictionaryInternal &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Return table &amp;nbsp;&amp;nbsp;&amp;nbsp; End Function End Class&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jun 2012 17:25:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/add-dbf-file-to-arcmap-table-of-contents/m-p/551054#M14906</guid>
      <dc:creator>DanWolford</dc:creator>
      <dc:date>2012-06-18T17:25:09Z</dc:date>
    </item>
    <item>
      <title>Re: Add DBF file to ArcMAP Table of Contents</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/add-dbf-file-to-arcmap-table-of-contents/m-p/551055#M14907</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This might be a data problem rather than a code problem.&amp;nbsp; Have you tried adding the dbf from the ArcMap add data command (not in code)?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jun 2012 17:44:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/add-dbf-file-to-arcmap-table-of-contents/m-p/551055#M14907</guid>
      <dc:creator>AlexanderGray</dc:creator>
      <dc:date>2012-06-18T17:44:19Z</dc:date>
    </item>
    <item>
      <title>Re: Add DBF file to ArcMAP Table of Contents</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/add-dbf-file-to-arcmap-table-of-contents/m-p/551056#M14908</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes and it opened fine.&amp;nbsp; The SHP\FINAL directory contains not only a DBF but all the files for the complete shape file format.&amp;nbsp; When I am in ArcMAP and click the ADD button it will not display the dbf if it is part of a shape file (it will display the shp file extension).&amp;nbsp; So I copied just the DBF to anoth directory and added it fine.&amp;nbsp; I can add the DBF's that I created with my program, but I can't add them programmatically for some reason.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jun 2012 18:08:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/add-dbf-file-to-arcmap-table-of-contents/m-p/551056#M14908</guid>
      <dc:creator>DanWolford</dc:creator>
      <dc:date>2012-06-18T18:08:34Z</dc:date>
    </item>
    <item>
      <title>Re: Add DBF file to ArcMAP Table of Contents</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/add-dbf-file-to-arcmap-table-of-contents/m-p/551057#M14909</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Does the program work if the dbf is alone in the folder?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jun 2012 18:26:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/add-dbf-file-to-arcmap-table-of-contents/m-p/551057#M14909</guid>
      <dc:creator>AlexanderGray</dc:creator>
      <dc:date>2012-06-18T18:26:32Z</dc:date>
    </item>
    <item>
      <title>Re: Add DBF file to ArcMAP Table of Contents</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/add-dbf-file-to-arcmap-table-of-contents/m-p/551058#M14910</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;No.&amp;nbsp; I've tried changing the variables tablePathName and tableName, but it won't work.&amp;nbsp; Both the AddTable and OpenTable routines were obtained from the following link.&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/Performing_basic_map_functions/000100000147000000/"&gt;Arc Objects/Working with the Map/Performing Basic map functions/&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;So you can see what I have changed and what I haven't.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jun 2012 18:45:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/add-dbf-file-to-arcmap-table-of-contents/m-p/551058#M14910</guid>
      <dc:creator>DanWolford</dc:creator>
      <dc:date>2012-06-18T18:45:54Z</dc:date>
    </item>
    <item>
      <title>Re: Add DBF file to ArcMAP Table of Contents</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/add-dbf-file-to-arcmap-table-of-contents/m-p/551059#M14911</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks argray1, I figured out what I was doing wrong with the routine.&amp;nbsp; I had the filename spelled different in one of the directories that I was testing.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jun 2012 19:24:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/add-dbf-file-to-arcmap-table-of-contents/m-p/551059#M14911</guid>
      <dc:creator>DanWolford</dc:creator>
      <dc:date>2012-06-18T19:24:57Z</dc:date>
    </item>
  </channel>
</rss>

