|
分類:[.NET 全般]
VC#2003でエクセルを起動したブックのセルの値をtextBoxに代入したいのですが、 下記ソースの最後の2行部分の記述でうまくいきません どなたか、教えてください。
// Excel object references. private Excel.Application m_objExcel ; private Excel.Workbooks m_objBooks = null; private Excel._Workbook m_objBook = null; private Excel.Sheets m_objSheets = null; private Excel._Worksheet m_objSheet = null; private Excel.Range m_objRange ;
private void listBox11_DoubleClick(object sender, System.EventArgs e) {
m_objExcel = new Excel.Application();
m_objBooks = (Excel.Workbooks)m_objExcel.Workbooks; m_objBook =( Excel._Workbook)m_objBooks._Open(strNamae,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing, Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing); m_objBook = m_objExcel.ActiveWorkbook; m_objSheets = (Excel.Sheets)m_objBook.Sheets;
// ワークシートを選択 m_objSheet = (Excel._Worksheet)(m_objSheets.get_Item(1)); // Microsoft Excel を表示する m_objExcel.Visible = true;
m_objRange = m_objSheet.get_Range("A1",Type.Missing);
string strCelValue = (m_objRange).Cells.ToString(); // ??????//
textBox2.Text = strCelValue.ToString(); // ??????//
}
|