OK, as I said in previous reply, there is no direct way to detach DataLink from a Table with COM API/VBA. The alternative is to directly delete the DataLink from drawing's NamedDictionary, if you do know the DataLink name and are sure the DataLink is only used by the table in interest.
Following code deletes a DataLink names as "TestTableData" from a drawing:
Public Sub Test()
Dim dic As AcadDictionary
On Error Resume Next
Set dic = ThisDrawing.Dictionaries("ACAD_DATALINK")
If Err.Number <> 0 Then Exit Sub
dic.Remove "TestTableData"
If Err.Number <> 0 Then
MsgBox "Cannot find item ""TestTableData"" in DataLink dictionary!"
Else
MsgBox "Datalink ""TestTableData"" has been removed successfully"
End If
End Sub
Hwever, after the DataLink is deleted from drawing's NamedDictionary, the table that uses this DataLink would still be data linked UNTIL you save the drawing, close it from AutoCAD. Once you reopen it in AutoCAD, you would see the table is no longer data linked, but the data from the previous DataLink remains.
Again, with AutoCAD .NET API, you can easily detach the datalink from table without having to deleting the DataLink itself, and you do not need to close the drawing for the detaching to take effect.
HTH