Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Visual C++ Excel Automation: Using Range::Sort

Status
Not open for further replies.

kikaxe

Programmer
Joined
Jul 22, 2002
Messages
1
Location
CA
Hello,

Does anyone have any experience using Range::Sort from the
Excel type library ?

I need to sort all the data using column A ascending as the
first key.

Here is a code snippet of what I've done so far:

//Common OLE variants. Easy variants to use for
//calling arguments
COleVariant
covTrue((short)TRUE),
covFalse((short)FALSE),
covOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR);

CString strCol1;
strCol1.Format("A%d", iStartRow);
lpDisp = sheet.GetRange(COleVariant(strCol1), COleVariant(strCol2));
ASSERT(lpDisp);
range.AttachDispatch(lpDisp);
range.Sort(COleVariant((CString)strCol1), 1,
covOptional,
covOptional,
0,
covOptional,
0,
0, covOptional, covOptional,
1,
1,
covOptional,
covOptional,
covOptional);

I keep getting an error using these parameters.
Does anyone know what each parameter means ?
(I haven't found any documentation on this).

Any help is greatly appreciated.

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top