khedkar

Hi,

I have created an Add-In project for Word 2007 in VSTO 2005. I have created a new Ribbon Tab with some buttons in it. On click of the button i need to open a a new file. I have the following code snippet in the Action for button click event in the ribbon:

public void OnOpenDocumentButton(Office.IRibbonControl control)

{

object missing = System.Reflection.Missing.Value;

object FileName = @"C:\Common\NewFile.docx";

Globals.ThisAddIn.Application.Documents.Open(ref FileName, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);

}

But this is not opening the document when i click on the button. The same code snippet i write in private void ThisAddIn_Startup(object sender, System.EventArgs e) it works. Am i going wrong somewhere

Any help will be appreciated.

Thanks

Manasi




Re: Visual Studio Tools for Office Unable to open an existing document from Ribbon button click event

Cindy Meister

Possibly the procedure isn't being called Have you tried putting a MessageBox.Show in it, just to make sure And remember to check the spelling, including capitalization, with the onAction property in the Ribbon XML.

Note that you should also put the code in a Try...catch block to prevent your Add-in becoming disabled if something causes an error.






Re: Visual Studio Tools for Office Unable to open an existing document from Ribbon button click event

colbert

Hi khedkar,

It maybe results from the Ribbion XML,can you post the ribbion.xml codes here.

Thanks