Passing an excel object between form classes

Joined
Dec 13, 2007
Messages
2
Reaction score
0
Hello,

I have an app where I am inporting data from Excel. I want to be able to give the user a dialog to choose which columns should be associated with which data elements in our app. I take the filename from the open dialog and open the workbook by doing:

// Get Workbooks collection.

lpDisp = app.GetWorkbooks(); // Get an IDispatch pointer

ASSERT(lpDisp); // or fail.

books.AttachDispatch( lpDisp ); // Attach the IDispatch pointer

// to the books object.

// Open a workbook.

lpDisp = books.Open(m_strFile,

covOptional, covOptional, covOptional, covOptional,

covOptional, covOptional, covOptional, covOptional,

covOptional, covOptional, covOptional, covOptional,

covOptional, covOptional);
// Excel 2000 has 13 parameters

ASSERT(lpDisp); // It worked!

// Attach to a Workbook object.

book.AttachDispatch( lpDisp ); // Attach the IDispatch pointer

// to the book object.

I want to pass the book object to the dialog. I pass the file name to display in the dialog with:

dlgExcelImport.m_ImportFileName =m_strFile;

and want to do something like:

dlgExcelImport.m_workbook= book;

However, I don't know how to declare m_workbook in dlgExcelImport.h.

I tried including excel.h in dlgExcelImport.h but get a humongous number of duplicate definitions (and it doesn't seem the right thing to do anyways) so that I can do:

_Workbook m_workbook; // Excel workbook object

So, any ideas? I'm sure I am just flummoxed by my own convoluted thought process.

thanks, in advance,

mark
 
Joined
Dec 13, 2007
Messages
2
Reaction score
0
Never mind! The reason for the duplifcate definitions is that I also had excel.h in the .cpp file that included the header file that I included excel.h in. My dumb!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top