2
我有一個C#Winforms程序,用以下代碼打開Excel文檔。 它工作的很好,但我不知道該怎麼做,是關閉所有菜單和工具欄。C#代碼隱藏excel文檔中的工具欄
我現在使用的excel版本是2003 ...但我將在不久的將來升級到2010年。 有什麼建議嗎?
//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, "\t", 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);
當我使用xlApp.CommandBars(「Worksheet Menu Bar」)。Enabled = False;代碼,我得到一個錯誤...不可用的成員'Microsoft.Office.Interop.Excel._Application.CommandBars'不能像方法一樣使用。如果我將其更改爲... xlApp.CommandBars [「Worksheet Menu Bar」]。Enabled = False;無法將索引與[]應用於'Microsoft.Office.Core.CommandBars' – Mouglue 2010-11-17 13:24:31
類型的表達式,我通過禁用('Enabled = false')測試了所有commadbars,但這沒有任何影響。儘管價值被正確應用。 – 2013-07-18 13:07:04