English 中文(简体)
C# Code to Hide toolbar in an excel document
原标题:C# code to Hide toolbars in an excel document

I have a C# Winforms program that opens an excel document with the code below. It works great but what I can not figure out how to do, is to turn off ALL menu s and toolbars.

The excel version I am using right now is 2003... But I will be upgrading to 2010 in the near future. Any ideas?

//top of source...
using Excel = Microsoft.Office.Interop.Excel;

// Code inside a function...

// Get report and display it on the screen.
Excel.Application xlApp;
Excel.Workbook xlWorkBook;
Excel.Worksheet xlWorkSheet;
object misValue = System.Reflection.Missing.Value;
xlApp = new Excel.ApplicationClass();

xlWorkBook = xlApp.Workbooks.Open(strFileName, 0, true, 5, "", "", true,Excel.XlPlatform.xlWindows, "	", false, false, 0, true, 1, 0);
xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
xlApp.Visible = true;
xlApp.DisplayFullScreen = true;

 // Display the Document and then Sleep.
System.Threading.Thread.Sleep(timeToShowMilliseconds);

// Close the Excel report 
 xlWorkBook.Close(false, misValue, misValue);
xlApp.Quit();

releaseObject(xlWorkSheet);
releaseObject(xlWorkBook);
releaseObject(xlApp);
问题回答

我先看你的情况,然后想到Excel.Application

Apparently what you need to do is something like this:

Excel.Application xlApp;
xlApp.CommandBars("tabName").Controls("File").Enabled = false;

试着它,让我知道,如果它不做工作,我们就会看到一些东西。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签