public static bool ChangeRibbonDisplay(IQuestion question, string filename, ShowHide display) { ExcelInterop.Application excelApplication = null; try { excelApplication = new ExcelInterop.Application() { Visible = false, DisplayAlerts = false, ScreenUpdating = false }; ExcelInterop.Workbook excelWorkbook = excelApplication.Workbooks.Open(filename); excelApplication.ExecuteExcel4Macro("show.toolbar(\"ribbon\"," + display + ")"); excelWorkbook.Save(); excelWorkbook.Close(true); return true; } catch (Exception) { return false; } finally { QuitApplication(excelApplication); } }
excelApplication.SendKeys("^{F1}");//not hide/show
excelApplication.CommandBars.ExecuteMso "HideRibbon"
HideRibbon
IdMso
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)