using System;
using Microsoft.Office.Interop.Excel;
using Microsoft.Office.Core;
namespace ConsoleApplication3
{
class Class1
{
///
/// Summary description for Class1.
///
private Application excel= new ApplicationClass();
private Workbook book= null;
private Worksheet sheet = null;
private CommandBar MainMenuBar = null;
private CommandBarControl MenuBarItem = null;
//private CommandBarButton MenuItem = null;
public Class1()
{
book = excel.Workbooks.Open("C:\\log.xls",0, true, 5, "", "", false, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "",true, false, 0, true, false, false);
InitMenuBarItems("My Main Menu");
excel.Visible=true;
sheet = (Worksheet)book.Sheets.get_Item(1);
Console.WriteLine("The file name is {0}",sheet.Name);
Console.ReadLine();
}
private void InitMenuBarItems(string Caption)
{
try
{
MainMenuBar =
excel.CommandBars["Worksheet Menu Bar"];
MenuBarItem = MainMenuBar.Controls.Add(
MsoControlType.msoControlPopup,
Type.Missing, Type.Missing, Type.Missing, true);
MenuBarItem.Caption = Caption;
}
catch
{
}
}
[STAThread]
static void Main(string[] args)
{
Class1 cls = new Class1();
}
}
}
Showing posts with label Creating Excel Menu from C#.net 2003. Show all posts
Showing posts with label Creating Excel Menu from C#.net 2003. Show all posts
Wednesday, April 2, 2008
Creating Excel Menu from Dot net 2003
Subscribe to:
Posts (Atom)