Click here to Skip to main content
15,898,996 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello,

Who can tel me what it is wrong in this code ?
I got an exception : 'System.Runtime.InteropServices.SEHException'
Thank you very much

C++
Excel::RangePtr ptrK1 = ptrSheet->Cells->GetItem(1,3);
_variant_t K1 = _variant_t (ptrK1);
Excel::RangePtr ptrK2 = ptrSheet->Cells->GetItem(1,4);
_variant_t K2 = _variant_t (ptrK2);
Excel::RangePtr ptrK3 = ptrSheet->Cells->GetItem(1,2);
_variant_t K3 = _variant_t (ptrK3);

Excel::XlSortOrder order = Excel::xlAscending;
Excel::XlSortType typ = Excel::xlSortLabels;
Excel::XlYesNoGuess head = Excel::xlYes;
Excel::XlSortOrientation orien = Excel::xlSortRows;
Excel::XlSortMethod meth = Excel::xlPinYin;
Excel::XlSortDataOption opt1 = Excel::xlSortNormal;
Excel::XlSortDataOption opt2 = Excel::xlSortNormal;
Excel::XlSortDataOption opt3 = Excel::xlSortNormal;

const _variant_t varM = vtMissing;

//&Key1, Order1, &Key2, &Type, Order2, &Key3, Order3, Header, &OrderCustom, &MatchCase, Orientation, SortMethod, DataOption1, DataOption2, DataOption3
ptrRng->Sort (&K1, order, &K2, &varM, order, &K3, order, head, &varM, &varM, orien, meth, opt1, opt2, opt3);



[EDIT]Code tags added - LOSMAC[/EDIT]
Posted
Updated 10-May-12 20:51pm
v2
Comments
Richard MacCutchan 11-May-12 4:36am    
Which line generated the exception, and what was the full text of the exception message?

1 solution

Hello

It is the sort instruction itself.
The exception is at the line 5812 in the excel.tli file.
In the "automatique" view debug, for the &Key1 there is "error:cannot obtain value"; it is the same for all others parameters _variant_t.

and the displayed text is :

Une exception non gérée du type 'System.Runtime.InteropServices.SEHException' s'est produite dans traitementfichiersoab.exe

Informations supplémentaires : Un composant externe a levé une exception.

thank you
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900