You would need to learn how to script 
(Sorry -- couldn't resist.)
I don't know how to code it into VBS, as I'm more a Javascript person, but since you only need to get the right ID for your tables, this Javascript should work just fine for you. Run it with your cursor somewhere (anywhere!) inside a table, and the pop-up alert shows you the ID. Then you can change that in your VBS.
This script looks like it's doing a lot of work, and you are correct. This one simple line ought to work
alert (app.selection[0].id);
but only if you always select the entire table! If you accidentally select just a single cell, you'll get the ID of that cell. For other selections (or none at all) you might just get an error message.
Since it's hard to remember (well, for me it is) "on" what sort of object any script should run, I usually build in a lot of checks, and when possible, try to get to the target from your current selection. That takes some care, as users are prone to trying to run some of my scripts in unexpected circumstances ... (e.g., without even having a document on screen). It also needs quite some background knowledge of how ID's object hierarchy works -- in this case, the parent-child relations of a table and everything inside it.
Enough about that. Let's get ta work.
The selection "length" should be '1', because the script cannot work with any multiple selections (i.e., like a number of rectangles). If you have nothing selected, the selection length is 0 and the script cannot work either ...
Then it checks if the selection has a property called "baseline". This would indicate you have a plain text cursor, somewhere inside (hopefully) a table cell. If so, the variable myTable is shifted up a notch to the plain text 'parent' -- which can be just about anything!
So a few more checks are needed. If the variable shifted "up" one level from text and you are inside a table, it will point to a Cell. Likewise, if you selected a single cell in its entirety, it will point to a Cell. If so, the next level 'up' is the table itself.
However, it's also possible to select an entire row or column -- and the selection will point to that instead! In both cases, the immediate parent is the table itself.
If you selected the entire table, all previous checks will fail and the selection type will be "Table" right away -- all previous checks will fail, but that doesn't really matter here.
Finally, if after all those checks "myTable" does point to a table, it shows the ID value in an alert box.
(Since this is a Javascript, copy and paste into a plain text editor -- Notepad, TextEdit in plain text mode, or Adobe's ESTK, for example -- and save as "ShowTableId.jsx" into your User Scripts folder.)
//DESCRIPTION:Show Table ID for a selected table
// Jongware, 14-May-2010
if (app.selection.length == 1)
{
myTable = app.selection[0];
if (myTable.hasOwnProperty ("baseline"))
myTable = myTable.parent;
if (myTable instanceof Cell)
myTable = myTable.parent;
if (myTable instanceof Row)
myTable = myTable.parent;
if (myTable instanceof Column)
myTable = myTable.parent;
if (myTable instanceof Table)
alert ("Table ID is "+myTable.id);
}