E
Einar Værnes
Hello, I'm trying to set up an Excel worksheet from MCVS, as described in
the samples found in
http://download.microsoft.com/download/office2000dev/sample/2/WIN98/EN-US/OFFAUTMN.EXE
I can successfully connect to EXCEL and put data into the cells as
described,
but if I try to do a Range::Sort on the worksheet I get problems.
In the header file excel8.h, in class Range there is a metod:
void Sort(
const VARIANT& Key1,
long Order1,
const VARIANT& Key2,
const VARIANT& Type,
long Order2,
const VARIANT& Key3,
long Order3, long Header,
const VARIANT& OrderCustom,
const VARIANT& MatchCase,
long Orientation,
long SortMethod,
const VARIANT& IgnoreControlCharacters,
const VARIANT& IgnoreDiacritics,
const VARIANT& IgnoreKashida);
I can not find any documentation on how to use this function anywhere,
and always gets an error message: "Sort method of Range class failed"
if I call it in this way:
...
...
oRange = oSheet.GetRange(COleVariant("A1:S100"),vOpt); // OK
oRange.Select();
// OK
oRange.Sort(
// FAIL : Sort method of Range class failed
COleVariant("D1"),
long("xlAscending"),
COleVariant("E1"),
COleVariant(long("xlSortValues"), VT_I4),
long("xlAscending"),
COleVariant("F1"),
long("xlAscending"),
long("xlYes"),
COleVariant(long(1), VT_I4),
COleVariant((long) FALSE, VT_BOOL),
long("xlTopToBottom"),
long("xlStroke"),
COleVariant((long) TRUE, VT_BOOL),
COleVariant((long) TRUE, VT_BOOL),
COleVariant((long) TRUE, VT_BOOL));
Can anyone give me a clue on how to make this work?
I'm using VC++ 6.0 and Excel 2002.
the samples found in
http://download.microsoft.com/download/office2000dev/sample/2/WIN98/EN-US/OFFAUTMN.EXE
I can successfully connect to EXCEL and put data into the cells as
described,
but if I try to do a Range::Sort on the worksheet I get problems.
In the header file excel8.h, in class Range there is a metod:
void Sort(
const VARIANT& Key1,
long Order1,
const VARIANT& Key2,
const VARIANT& Type,
long Order2,
const VARIANT& Key3,
long Order3, long Header,
const VARIANT& OrderCustom,
const VARIANT& MatchCase,
long Orientation,
long SortMethod,
const VARIANT& IgnoreControlCharacters,
const VARIANT& IgnoreDiacritics,
const VARIANT& IgnoreKashida);
I can not find any documentation on how to use this function anywhere,
and always gets an error message: "Sort method of Range class failed"
if I call it in this way:
...
...
oRange = oSheet.GetRange(COleVariant("A1:S100"),vOpt); // OK
oRange.Select();
// OK
oRange.Sort(
// FAIL : Sort method of Range class failed
COleVariant("D1"),
long("xlAscending"),
COleVariant("E1"),
COleVariant(long("xlSortValues"), VT_I4),
long("xlAscending"),
COleVariant("F1"),
long("xlAscending"),
long("xlYes"),
COleVariant(long(1), VT_I4),
COleVariant((long) FALSE, VT_BOOL),
long("xlTopToBottom"),
long("xlStroke"),
COleVariant((long) TRUE, VT_BOOL),
COleVariant((long) TRUE, VT_BOOL),
COleVariant((long) TRUE, VT_BOOL));
Can anyone give me a clue on how to make this work?
I'm using VC++ 6.0 and Excel 2002.