CG

CG

  • NA
  • 22
  • 0

Export to excel

Jan 2 2009 4:34 AM

Hi,

       Does anybody know how to start a new work book from a windows form? I found this on Microsoft's website but I keep getting the error message "The Name m_objExcel does not exsist in the current context".

using System;

using System.Collections.Generic;

using System.Drawing;

using System.Windows.Forms;

using Microsoft.Office.Interop.Excel;

using Excel;

namespace copy

{

/// <summary>

/// Description of MainForm.

/// </summary>

public partial class MainForm : Form

{

public MainForm()

{

InitializeComponent();

}

public void Button1Click(object sender, EventArgs e)

{

m_objExcel = new Excel.Application();

m_objBooks = (Excel.Workbooks)m_objExcel.Workbook;

m_objBook = (Excel._Workbook)(m_objBooks.Add(m_objOpt));

}

}

}

Thanks in advance...


Answers (5)