Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Formatting the excel window
Hi,
I am opening an excel file within a windows form. I want the user to only play around with the excel area. The user should not create or open an excel file. So I want to hide the menu bar and disable the New and Open standard toolbar buttons. I use the following C# code to achieve my goal: Code Snippet// xlApp is the instance of Excel.Application xlApp.WindowState = Excel.XlWindowState.xlMaximized; // Hide the Menu bar int counter = xlApp.ActiveWindow.Application.CommandBars.Count; for (int i = 1; i <= counter; i++) { try { string nm = xlApp.ActiveWindow.Application.CommandBars[i].Name; if (nm == "Standard") { int count_control = xlApp.ActiveWindow.Application.CommandBars[i].Controls.Count; for (int j = 1; j <= 2; j++) { xlApp.ActiveWindow.Application.CommandBars[i].Controls[j].Enabled = false; } } if (nm == "Worksheet Menu Bar") { xlApp.ActiveWindow.Application.CommandBars[i].Enabled = false; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } // Show the necessary command bars xlApp.CommandBars["Standard"].Visible = true; xlApp.CommandBars["Standard"].Position = Office.MsoBarPosition.msoBarTop; xlApp.CommandBars["Visual Basic"].Visible = true; xlApp.CommandBars["Visual Basic"].Position = Office.MsoBarPosition.msoBarTop; xlApp.CommandBars["Formatting"].Visible = true; xlApp.CommandBars["Formatting"].Position = Office.MsoBarPosition.msoBarTop; The problem now is that at times this code works fine and I see only the necessary buttons and toolbars but at times I dont see any toolbar button. Can somebody please explain this strange behaviour? Is there a standard code to hide/show excel buttons/toolbars? (I am using C# with Office 2000) Regards, Asim. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Formatting excel to open in a window that is full screen | Excel Worksheet Functions | |||
The window opens in a smaller window not full sized window. | Excel Discussion (Misc queries) | |||
In Excel - how to delete new window created from window on tool ba | Excel Worksheet Functions | |||
How do I undo the Excel, Window Menu, New Window command | Excel Discussion (Misc queries) | |||
Formatting of workbook window | Excel Programming |