<?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: How do you add a stand alone table to the map document using ArcObjects? in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-do-you-add-a-stand-alone-table-to-the-map/m-p/278009#M7170</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank You Duncan for the help. I was able to get it working. I also used ITableWindow to open the table that was added using the example you provided. The trick with ITableWindow is to point it to the Application.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
ITableWindow tabwindow = new TableWindow();
tabwindow.Application = Application;
tabwindow.Table = Table;
tabwindow.Show(true);
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Greg&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 13:32:24 GMT</pubDate>
    <dc:creator>GregRieck</dc:creator>
    <dc:date>2021-12-11T13:32:24Z</dc:date>
    <item>
      <title>How do you add a stand alone table to the map document using ArcObjects?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-do-you-add-a-stand-alone-table-to-the-map/m-p/278003#M7164</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello, Does any one know how to do the following using ArcObjects:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1) determine if a stand-alone table is already in the map document&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2) determine if a stand-alone table is already opened in the map document&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3) add and/or open a stand-alone table based on above results&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;4) make the stand-alone table the selected table, i.e. has focus after being added to the map document.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank You,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Greg&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is what I've been able to work up so far, but it doesn't add the table to the map document...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
IStandaloneTable addThisTable = null;
IFeatureWorkspace fws = Editor3.EditWorkspace as IFeatureWorkspace;
if (fws != null)
{
&amp;nbsp; addThisTable = fws.OpenTable("TableToBeAdded") as IStandaloneTable;
&amp;nbsp; if (addThisTable&amp;nbsp; != null)
&amp;nbsp;&amp;nbsp;&amp;nbsp; return Result.Success();
}
bool isFound = false;
IEnumTableProperties pEnumTP = MxDoc.TableProperties.IEnumTableProperties;
pEnumTP.Reset();
ITableProperty3 pTP3 = pEnumTP.Next() as ITableProperty3;
while (pTP3 != null)
{
&amp;nbsp; if (pTP3.StandaloneTable != null)
&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (pTP3.StandaloneTable.Name.ToLower() == "TableToBeAdded")
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; isFound = true;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp; }
&amp;nbsp; pTP3 = pEnumTP.Next() as ITableProperty3;
}
if (!isFound)
{
&amp;nbsp; pTP3 = new TableProperty() as ITableProperty3;
&amp;nbsp; pTP3.StandaloneTable = addThisTable;
&amp;nbsp; pTP3.SelectedTable = true;
&amp;nbsp; MxDoc.TableProperties.Add(pTP3 as ITableProperty);
}
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 27 Nov 2010 16:32:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-do-you-add-a-stand-alone-table-to-the-map/m-p/278003#M7164</guid>
      <dc:creator>GregRieck</dc:creator>
      <dc:date>2010-11-27T16:32:22Z</dc:date>
    </item>
    <item>
      <title>Re: How do you add a stand alone table to the map document using ArcObjects?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-do-you-add-a-stand-alone-table-to-the-map/m-p/278004#M7165</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Greg,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To add or find a table in the map document you need to be using the&amp;nbsp; IStandaloneTableCollection&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Interface. You can loop with this to compare names of tables in the collection. There is no "find the table with this name" function you must enumerate the collection.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Duncan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 27 Nov 2010 17:14:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-do-you-add-a-stand-alone-table-to-the-map/m-p/278004#M7165</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2010-11-27T17:14:18Z</dc:date>
    </item>
    <item>
      <title>Re: How do you add a stand alone table to the map document using ArcObjects?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-do-you-add-a-stand-alone-table-to-the-map/m-p/278005#M7166</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Greg,&lt;BR /&gt;&lt;BR /&gt;To add or find a table in the map document you need to be using the&amp;nbsp; IStandaloneTableCollection&lt;BR /&gt; Interface. You can loop with this to compare names of tables in the collection. There is no "find the table with this name" function you must enumerate the collection.&lt;BR /&gt;&lt;BR /&gt;Duncan&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Great, thanks for the tip. Do you have any sample code for working with IStandaloneTableCollection?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Greg&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 27 Nov 2010 19:52:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-do-you-add-a-stand-alone-table-to-the-map/m-p/278005#M7166</guid>
      <dc:creator>GregRieck</dc:creator>
      <dc:date>2010-11-27T19:52:13Z</dc:date>
    </item>
    <item>
      <title>Re: How do you add a stand alone table to the map document using ArcObjects?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-do-you-add-a-stand-alone-table-to-the-map/m-p/278006#M7167</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Greg,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is a simple bit of code in VBA to get you going.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Sub test()
&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Get document
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pMXDocument As IMxDocument
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pMXDocument = ThisDocument
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Get Map
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pMap As IMap
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pMap = pMXDocument.FocusMap
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Get table collection
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pStandaloneTableCollection As IStandaloneTableCollection
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pStandaloneTableCollection = pMap
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Get a count of tables
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim n As Integer
&amp;nbsp;&amp;nbsp;&amp;nbsp; Let n = pStandaloneTableCollection.StandaloneTableCount
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Step through each table and print name
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pStandaloneTable&amp;nbsp; As IStandaloneTable
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim i As Integer
&amp;nbsp;&amp;nbsp;&amp;nbsp; For i = 0 To (n - 1)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pStandaloneTable = pStandaloneTableCollection.StandaloneTable(i)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.Print pStandaloneTable.Name
&amp;nbsp;&amp;nbsp;&amp;nbsp; Next i
End Sub&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Duncan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:32:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-do-you-add-a-stand-alone-table-to-the-map/m-p/278006#M7167</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2021-12-11T13:32:15Z</dc:date>
    </item>
    <item>
      <title>Re: How do you add a stand alone table to the map document using ArcObjects?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-do-you-add-a-stand-alone-table-to-the-map/m-p/278007#M7168</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Duncan,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you, already had that part working. I should have been more precise with my question. I was having issues "adding" the standalone table to the map document. I found that you have to call UpdateContents on the map document to get the new table to appear. Now all I have left is to actually open the newly added table and make sure that table has focus.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Greg&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Greg,&lt;BR /&gt;&lt;BR /&gt;Here is a simple bit of code in VBA to get you going.&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Sub test()
&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Get document
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pMXDocument As IMxDocument
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pMXDocument = ThisDocument
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Get Map
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pMap As IMap
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pMap = pMXDocument.FocusMap
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Get table collection
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pStandaloneTableCollection As IStandaloneTableCollection
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pStandaloneTableCollection = pMap
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Get a count of tables
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim n As Integer
&amp;nbsp;&amp;nbsp;&amp;nbsp; Let n = pStandaloneTableCollection.StandaloneTableCount
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Step through each table and print name
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pStandaloneTable&amp;nbsp; As IStandaloneTable
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim i As Integer
&amp;nbsp;&amp;nbsp;&amp;nbsp; For i = 0 To (n - 1)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pStandaloneTable = pStandaloneTableCollection.StandaloneTable(i)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.Print pStandaloneTable.Name
&amp;nbsp;&amp;nbsp;&amp;nbsp; Next i
End Sub&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;Duncan&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:32:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-do-you-add-a-stand-alone-table-to-the-map/m-p/278007#M7168</guid>
      <dc:creator>GregRieck</dc:creator>
      <dc:date>2021-12-11T13:32:18Z</dc:date>
    </item>
    <item>
      <title>Re: How do you add a stand alone table to the map document using ArcObjects?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-do-you-add-a-stand-alone-table-to-the-map/m-p/278008#M7169</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Greg,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is the VBA code for loading a table into the map document:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Sub test2()
&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Get document
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pMXDocument As IMxDocument
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pMXDocument = ThisDocument
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Get Map
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pMap As IMap
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pMap = pMXDocument.FocusMap
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Get table collection
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pStandaloneTableCollection As IStandaloneTableCollection
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pStandaloneTableCollection = pMap
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Create workspacefactory (for opening up dBase files)
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pWorkspaceFactory As IWorkspaceFactory
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pWorkspaceFactory = New ShapefileWorkspaceFactory
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pFeatureWorkSpace As IFeatureWorkspace
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pFeatureWorkSpace = pWorkspaceFactory.OpenFromFile("C:\Temp", 0)
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Get dBase table
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pTable As ITable
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pTable = pFeatureWorkSpace.OpenTable("testtable") ' note no .dbf
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Create StandaloneTable
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pStandaloneTable&amp;nbsp; As IStandaloneTable
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pStandaloneTable = New StandaloneTable
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pStandaloneTable.Table = pTable
&amp;nbsp;&amp;nbsp;&amp;nbsp; pStandaloneTable.Name = "My Table"
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Add table to Map
&amp;nbsp;&amp;nbsp;&amp;nbsp; pStandaloneTableCollection.AddStandaloneTable pStandaloneTable
&amp;nbsp;&amp;nbsp;&amp;nbsp; pMXDocument.UpdateContents
End Sub&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Duncan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:32:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-do-you-add-a-stand-alone-table-to-the-map/m-p/278008#M7169</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2021-12-11T13:32:21Z</dc:date>
    </item>
    <item>
      <title>Re: How do you add a stand alone table to the map document using ArcObjects?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-do-you-add-a-stand-alone-table-to-the-map/m-p/278009#M7170</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank You Duncan for the help. I was able to get it working. I also used ITableWindow to open the table that was added using the example you provided. The trick with ITableWindow is to point it to the Application.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
ITableWindow tabwindow = new TableWindow();
tabwindow.Application = Application;
tabwindow.Table = Table;
tabwindow.Show(true);
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Greg&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:32:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-do-you-add-a-stand-alone-table-to-the-map/m-p/278009#M7170</guid>
      <dc:creator>GregRieck</dc:creator>
      <dc:date>2021-12-11T13:32:24Z</dc:date>
    </item>
  </channel>
</rss>

