I use VS 2010 for creating Excel 2007 xltx template. I want to remove all Excel command bars and disable to show them users and add own command bar with my controls. And in some controls I want to call VBA function that will be in this template. I think this operation I must do in :
private void ThisWorkbook_Startup(object sender, System.EventArgs e)
{
}
private void ThisWorkbook_Shutdown(object sender, System.EventArgs e)
{
}
Any suggestion? Thanks.
I use VS 2010 for creating Excel 2007 xltx template. I want to remove all Excel command bars and disable to show them users and add own command bar with my controls. And in some controls I want to call VBA function that will be in this template. I think this operation I must do in :
private void ThisWorkbook_Startup(object sender, System.EventArgs e)
{
}
private void ThisWorkbook_Shutdown(object sender, System.EventArgs e)
{
}
Any suggestion? Thanks.
UPD1:
I try :
private void ThisWorkbook_Startup(object sender, System.EventArgs e)
{
foreach (CommandBar bar in this.Application.ThisWorkbook.CommandBars)
{
bar.Visible = false;
//or bar.Delete();
}
}
But I get error: System.Runtime.InteropServices.COMException (0x800A03EC): Exception from HRESULT: 0x800A03EC
at Microsoft.Office.Interop.Excel._Application.get_ThisWorkbook()
at T100.ThisWorkbook.ThisWorkbook_Startup(Object sender, EventArgs e) in G:\PROJECTS\T100\T100\ThisWorkbook.cs:line 20
at Microsoft.Office.Tools.Excel.WorkbookImpl.OnStartup()
at Microsoft.Office.Tools.Excel.WorkbookImpl.WorkbookExtensionImpl.Microsoft.Office.Tools.EntryPoint.OnStartup()
at Microsoft.Office.Tools.Excel.WorkbookBase.OnStartup()
at T100.ThisWorkbook.FinishInitialization() in G:\PROJECTS\T100\T100\ThisWorkbook.Designer.cs:line 57
at Microsoft.Office.Tools.Excel.WorkbookBase.Microsoft.Office.Tools.EntryPoint.FinishInitialization()
at Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.ExecuteCustomization.ExecutePhase(ExecutionPhases executionPhases)
at Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.ExecuteCustomization.Microsoft.VisualStudio.Tools.Office.Runtime.Interop.IExecuteCustomization2.ExecuteEntryPoints()
Add new ribbon to your project and set this in your ribbon xml
If you use the ribbon designer you can find startFromScratch property in your properties window set this to “true”.