Can I change the behavior of the Insert Table command in Word 2007?

In Word 2007, the Ribbon Insert tab has a Tables group with one drop-down button (indicated by "Table").

The drop-down list contains various menu items, such as "Insert table ...", "Drawing table", etc. However, at the top of the drop-down list there is a 10x8 grid that you can use to quickly select the size of your new table with the mouse. (First question: what is this thing? !!).

I would like to override the default behavior, so that when the user "draws" the table using the widget mentioned above, I can change the paragraph style used in the table (and possibly do a different cleanup).

I know how to override the "Insert table ..." command, but I cannot figure out how to override the "widget" behavior. It can be done?

+4
source share
1 answer

Before you start reading (because it will be long), I want to say that I did not solve this problem. However, in my attempts to solve and then get around this problem, I found a lot of things that I write down here, hoping that they will help someone find a solution.

When trying to determine what a 10x8 grid controls that can be used to insert a table, I discovered a macro specified in Word commands called "TableInsertGeneral".

TableInsertGeneral listed in Word Macros dialog box

This macro, according to Suzanne S. Barnhill, will restore the grid if this function ceases to function in earlier versions of Word ( Insert Drop Down Missing Table ). A macro, since it exists in Word 2007/2010, cannot be executed from the Run button of the macro dialog. Double-clicking on a command rejects the dialog box, but does nothing more open. I also tried to intercept its function by creating a VBA submenu called TableInsertGeneral, but the code that I placed in this sub did not execute when I accessed the grid. However, based on my research, I believe the TableInsertGeneral macro has some connection to display a 10x8 grid.

I also tried to solve the problem by changing the gallery of tables in the Word ribbon. Since I could not directly access the code that controlled the grid, I tried to hide the table of tables and then replace it with a rebuilt gallery that excluded the grid function (so that the paragraph style and other changes worked globally).

First I downloaded a few tools:

Using the User Interface Editor for Microsoft Office (which allows you to edit the customui.xml file inside a Word 2007 document or template without having to create folder structures or maintain relationships between xml files). I opened the template and saved this code in a file:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui"> <ribbon> <tabs> <tab idMso="TabInsert"> <group idMso="GroupInsertTables" visible="false" /> <group id="CustomGroupInsertTables" label="Tables" insertBeforeMso="GroupInsertIllustrations"> <gallery id="CustomTableInsertGallery" label="Table" imageMso="TableInsertGallery" size="large" columns="1" rows="4" screentip="Table" supertip="Insert or draw a table into the document." keytip="T" onAction="RibbonControl.galleryOnAction" > <item id="GridMessage" label="Draw Table Via Grid Has Been Removed" imageMso="TablesGallery" supertip="Provides information on why this template has different Ribbon controls."/> <button idMso="TableInsertDialogWord" /> <button idMso="ConvertTextToTable" /> <button idMso="TableExcelSpreadsheetInsert" /> </gallery> </group> </tab> </tabs> </ribbon> </customUI> 

This successfully hid the source table of the tables and replaced it with some functions of the source table. The 10x8 grid disappeared, but I was unable to restore the Draw Table Toggle button and Quick Tables. As far as I can tell, the XML schema does not allow embedding any of them (which exist in the finished version of Word 2007) into the existing gallery. Since I do not like to remove functionality (even for this partial solution, which I thought would not be used), I added a button tied to the message box as the first element in the rebuilt gallery:

Rebuilt Tables Gallery

The code for connecting a new button โ€œDraw a table through the grid removedโ€ was placed in a module named RibbonControl:

 Sub GalleryOnAction(Control As IRibbonControl, selectedID As String, selectedIndex As Integer) If Documents.Count = 0 Then MsgBox "This control is disabled when there is no active document." Exit Sub End If Select Case Control.id Case "CustomTableInsertGallery" Select Case selectedIndex Case 0 MsgBox "Explain changes to Ribbon interface here." Case Else 'Do Nothing End Select End Select End Sub 

I do not expect anyone to use this partial solution, however, if it were possible to recover the two missing controls, this could be a good workaround. By the way, I adapted most of this from Greg Max's website:

Ribbon Setting

If you read this, thanks! And I wish you more success with your own efforts.

+3
source

All Articles