Bogus
December 3rd, 2005, 12:15 PM
How to pass optional argument in Managed C++ code to the method accessed via COM.
My problem:
I try to operate with MS Excel objects. Sheets object Add method has several optional arguments which I try to omit.
MS Excel Programmers guide says:
"expression.Add(Before, After, Count, Type)
...
Before Optional Variant. An object that specifies the sheet before which the new sheet is added.
After Optional Variant. An object that specifies the sheet after which the new sheet is added.
...
If Before and After are both omitted, the new sheet is inserted before the active sheet."
In managed C++ I have the following code line:
using namespace Interop;
using namespace Interop::Excel;
Excel::Sheets *m_sheets;
/*m_sheets has been initialised with m_sheets = m_book->get_Worksheets(); and so on*/
m_sheets->Add( optionalArgument, optionalArgument, __box(howManySheets), __box(XlSheetType::xlWorksheet));
Exact question:
How to declare and initialise optionalArgument not to obtain:
System.Runtime.InteropServices.COMException - Exception from HRESULT 0x800A03EC ?
My problem:
I try to operate with MS Excel objects. Sheets object Add method has several optional arguments which I try to omit.
MS Excel Programmers guide says:
"expression.Add(Before, After, Count, Type)
...
Before Optional Variant. An object that specifies the sheet before which the new sheet is added.
After Optional Variant. An object that specifies the sheet after which the new sheet is added.
...
If Before and After are both omitted, the new sheet is inserted before the active sheet."
In managed C++ I have the following code line:
using namespace Interop;
using namespace Interop::Excel;
Excel::Sheets *m_sheets;
/*m_sheets has been initialised with m_sheets = m_book->get_Worksheets(); and so on*/
m_sheets->Add( optionalArgument, optionalArgument, __box(howManySheets), __box(XlSheetType::xlWorksheet));
Exact question:
How to declare and initialise optionalArgument not to obtain:
System.Runtime.InteropServices.COMException - Exception from HRESULT 0x800A03EC ?