Hello, Does any one know how to do the following using ArcObjects:1) determine if a stand-alone table is already in the map document2) determine if a stand-alone table is already opened in the map document3) add and/or open a stand-alone table based on above results4) make the stand-alone table the selected table, i.e. has focus after being added to the map document.Thank You,GregHere is what I've been able to work up so far, but it doesn't add the table to the map document...
IStandaloneTable addThisTable = null;
IFeatureWorkspace fws = Editor3.EditWorkspace as IFeatureWorkspace;
if (fws != null)
{
addThisTable = fws.OpenTable("TableToBeAdded") as IStandaloneTable;
if (addThisTable != null)
return Result.Success();
}
bool isFound = false;
IEnumTableProperties pEnumTP = MxDoc.TableProperties.IEnumTableProperties;
pEnumTP.Reset();
ITableProperty3 pTP3 = pEnumTP.Next() as ITableProperty3;
while (pTP3 != null)
{
if (pTP3.StandaloneTable != null)
{
if (pTP3.StandaloneTable.Name.ToLower() == "TableToBeAdded")
{
isFound = true;
break;
}
}
pTP3 = pEnumTP.Next() as ITableProperty3;
}
if (!isFound)
{
pTP3 = new TableProperty() as ITableProperty3;
pTP3.StandaloneTable = addThisTable;
pTP3.SelectedTable = true;
MxDoc.TableProperties.Add(pTP3 as ITableProperty);
}