Jim Bassett
August 20th, 1999, 08:26 AM
Below is a code section where I am trying to create another worksheet in an Excel application using automation. The Excel application starts up with 3 wooksheets. I get a "Sheet creation failed" on line number 4. This is really giving me a hard time and I can't make sense why this is not working. What am I doing wrong.
1) m_Excel_books = m_Excel_app.GetWorkbooks();
2) m_Excel_book = m_Excel_books.Add(covOptional);
// Get the first sheet
3) m_Excel_sheets = m_Excel_app.GetWorksheets(); // m_Excel_sheets is a WorkSheets type
4 )m_Excel_sheets.Add(COleVariant((short)2), COleVariant((short)1), COleVariant((short)1), COleVariant(xlWorksheet)); // xlWorksheet = -4167
1) m_Excel_books = m_Excel_app.GetWorkbooks();
2) m_Excel_book = m_Excel_books.Add(covOptional);
// Get the first sheet
3) m_Excel_sheets = m_Excel_app.GetWorksheets(); // m_Excel_sheets is a WorkSheets type
4 )m_Excel_sheets.Add(COleVariant((short)2), COleVariant((short)1), COleVariant((short)1), COleVariant(xlWorksheet)); // xlWorksheet = -4167