Hi everybody,
I'm trying to open a Excel File using VC++ 2005 but i get a compiling error.
I proceed like this:
Firstly, I add the references "Microsoft Excel 9.0 Object Library" and "Microsoft Office 9.0 Object Library"
Secondly, I add the excel namespace
using namespace System;
using namespace System::IO;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace Excel;
Then I declare the following variables
public:
Excel::ApplicationClass^ xExcel;
Excel::Workbooks^ xWorkbooks;
Excel::Worksheets^ xWorksheets;
and finally I try to create an instance of the Excel application as follows:
private: System::Void openToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e)
{
OpenFileDialog^ OFDB = gcnew OpenFileDialog;
Stream^ InputFile;
OFDB->InitialDirectory = "c:\\";
OFDB->Filter = "xls files (*.xls)|*.xls";
OFDB->FilterIndex = 2;
OFDB->RestoreDirectory = true;
if ( OFDB->ShowDialog() == System::Windows::Forms::DialogResult::OK )
{
xExcel=gcnew Excel::ApplicationClass();
}
}
But I get the following compiling error in the code line "xExcel=gcnew Excel::ApplicationClass();"
d:\visual studio projects\vc++\excel file handler\excel file handler\Form1.h(150) : error C3699: '^' : cannot use this indirection on type 'Office::Assistant'
compiler replacing '^' with '*' to continue parsing
This diagnostic occurred while importing type 'Excel::_Application ' from assembly 'Interop.Excel.1.3, Version=1.3.0.0, Culture=neutral, PublicKeyToken=null'.
This diagnostic occurred while importing type 'Excel::ApplicationClass ' from assembly 'Interop.Excel.1.3, Version=1.3.0.0, Culture=neutral, PublicKeyToken=null'.
d:\visual studio projects\vc++\excel file handler\excel file handler\Form1.h(150) : error C3699: '^' : cannot use this indirection on type 'Office::Assistant'
.
.
.
Could anybody help me with this please?
Thanks