Lei Hua

Dear Microsoft Support Team,

We need to customize Word 2007 tool bars, one of the problems is, we want to show our own templates as the default and only templates when initiate a new word document. How can we do that Do we need to develop Office Add-in COM+ Or we can archive that by simply modifying the configuration XML files Or tell us if it is not possible at all, so we won't spend extra effort to do the research.

Our environment:

Vista and MS Office 2007 Enterprise Edition




Re: Visual Studio Tools for Office office 2007 question??? (Please help me!)

Savraj

Hi Lei,

Yes, if I understand what you are asking, it is possible. You can take over the built-in New button so that, when you click it, it always opens YOUR dialog with your set of custom templates. This is possible with the Command repurposing feature of RibbonX. You can read more about how ribbonX works at http://msdn.microsoft.com/office/tool/ribbon

You should be able to do this with a COM or a VBA add-in.

-Savraj






Re: Visual Studio Tools for Office office 2007 question??? (Please help me!)

Lei Hua

Hello Savraj

Thank you for helping me. I try to use VS 2005 tools for office 2007 and design a project for customize office user interface.It works fine. But I want to remove office 2007 default template such as microsoft online template tab in new document form. And I want to remove Faxes,Letters,Other Documents,Reports and Resumes these default template tabs if I click new document button and select my template. Could you have any ideas for customize template forms

Lei






Re: Visual Studio Tools for Office office 2007 question??? (Please help me!)

Ji Zhou – MSFT

Hi Lei,

No. The template dialog cannot be customized, as far as I know.

The closest approach I can think out is that, we can use Ribbon Customization to hide the built-in New Button in Office Menu, and create our own button which performs the new-document process according to our wish.

The ribbon customized xml file looks like:

Code Block

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="OnLoad">

<ribbon>

<officeMenu>

<button idMso="FileNew" visible="false"/>

<button id ="MyNew" insertBeforeMso="FileNew" onAction="CallBack"

imageMso="FileNew" label="New"/>

</officeMenu>

</ribbon>

</customUI>

And you can implement your codes about creating documents in the onAction function: “CallBack”. This workaround has a disadvantage. User still can customize Quick Access Toolbar, and add the built-in onto the Quick Access Toolbar.

Thanks

Ji






Re: Visual Studio Tools for Office office 2007 question??? (Please help me!)

Lei Hua

Hi Ji

Thank you so much! I will try to do that. We found same way to customize office menu.

Best Regards

Lei Hua






Re: Visual Studio Tools for Office office 2007 question??? (Please help me!)

Savraj

Hi Ji and Lei,

There is a much better way to do this. You can take over the built-in File New command with RibbonX. This means that when you click it, your dialog is opened instead of the built-in dialog. This is better because:

1) less code
2) Even if you add the File New button to the QAT, it does what you want (opens your dialog)
3) you do not need to hide the built-in button and create a new button.
4) You get the appropriate state behaviors, (built-in disabling, enabling of the control at the right times) for free

Here is the ribbonX code to 'take over' the built-in file new button.

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<commands>
<command idMso="FileNew" onAction="callBack"/>
</commands>
</customUI>

And here is the Callback:
public void callBack(Office.IRibbonControl control, ref bool cancelDefault)
{
MessageBox.Show("hello");
cancelDefault = true;
}


The Callback has a special "Cancel Default" variable. If set to true, the default action (opening the built-in template dialog, in this case) is canceled. If false, your code runs, and then the built-in code runs.

-Savraj





Re: Visual Studio Tools for Office office 2007 question??? (Please help me!)

Ji Zhou – MSFT

Hi Savraj,

Thanks for the effort on exploring and sharing! Yeah, you are right! I was missing that. It is so good and appreciated that members here spend their time on helping each other.

Thanks again!

Ji