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
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