Home › Forums › General XMetaL Discussion › Insert Table functionality › Reply To: Insert Table functionality
Reply to: Insert Table functionality
March 11, 2013 at 5:26 pmI think you will need to create a macro and hook it up to a button or menu item.
The logic in the macro will depend on exactly what you want to accomplish but at minimum you would probably call FindInsertLocation() and you'll probably want to check if it succeeded. If it succeeded then you can have it launch Table > Insert Table, or you could have it launch your own custom insert table dialog.
To launch the built-in Insert Table function, and assuming the Table menu hasn't been modified, you could call it like this:
// XMetaL Script Language JSCRIPT:
var mainMenu = Application.CommandBars.item("Menu bar");
var tableMenu= mainMenu.Controls.item("Table");
var insertTableCmd = tableMenu.Controls.item(1);
insertTableCmd.Execute();
To launch it from the Table toolbar, and assuming the Table toolbar hasn't been modified, you could call it like this:
// XMetaL Script Language JSCRIPT:
var tableToolbar = Application.CommandBars.item("Table");
var insertTableCmd = tableToolbar.Controls.item(1);
insertTableCmd.Execute();
Those are just quick examples. To be robust (some users do change menus and toolbars around — unless you have disabled that feature) you might implement code that sets the “insertTableCmd” based on looking for the actual menu item's title (probably “Insert &Table…”).
For info on launching your own custom dialog (XFT) see CreateFormDlg() in the Programmers Guide.