Moataz Aahmed Mohammed
Moataz Aahmed Mohammed

Reputation: 1297

How can change start up in Office 2010 Automation C# Application

I'm trying to create new Office excel workbook application how can i change start-up of this application to start with windows form instead of opening excel.

Thanks Like This

Upvotes: 1

Views: 299

Answers (1)

nawfal
nawfal

Reputation: 73253

  1. Create two projects under your solution, one a winforms (or whatever it is), the other excel workbook application.

  2. Set Winforms application as your startup project.

  3. Reference excel application project to your winforms project.

  4. Open up Excel application from your code in winforms project when required. Like this or so:

    using (Process excelProcess = new Process())
    {
        excelProcess.StartInfo.FileName = Assembly.GetAssembly(typeof(SomeClassInExcelApplicationProject)).Location;
        excelProcess.Start();
    }
    

    If you want winforms to close upon starting excel application, add Application.Exit(); after starting excel application process

Upvotes: 3

Related Questions