C
cbsok
Unregistered / Unconfirmed
GUEST, unregistred user!
ExcelApplication,ExcelWorkBook,ExcelWorkSheet都能正确使用
怎样使用Range.Sort方法
procedure TDataModuleMyExcel.MySort;
var
DataRange:Range;
key1:OleVariant;
begin
ExcelWorksheet1.Activate;
DataRange:=ExcelWorksheet1.Range['A1','A1'].CurrentRegion;
DataRange.Select;
//Key1:='Range("M2")';
TvarData(Key1).VType:=varDispatch;
TvarData(Key1).VDispatch:='Range("A2")';
DataRange.Sort(key1,xlDescending,
Emptyparam,Emptyparam,Emptyparam,Emptyparam,Emptyparam,
xlGuess,1,False,xlTopToBottom,xlPinYin);
运行时报错
vba宏如下
{' cbsok 记录的宏 2004-6-3
Selection.Sort Key1:=Range("A2"), Order1:=xlDescending,Header:=xlGuess,_
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom,SortMethod_
:=xlPinYin, DataOption1:=xlSortTextAsNumbers}
查到的资料
IRange
function Sort(Key1: OleVariant; Order1: XlSortOrder; Key2: OleVariant; Type_: OleVariant;
Order2: XlSortOrder; Key3: OleVariant; Order3: XlSortOrder; Header: XlYesNoGuess;
OrderCustom: OleVariant; MatchCase: OleVariant; Orientation: XlSortOrientation;
SortMethod: XlSortMethod; out RHS: OleVariant): HResult; stdcall;
Excel Macro
Selection.Sort Key1:=Range("B2"), Order1:=xlAscending, Key2:=Range("C2") _
, Order2:=xlAscending, Key3:=Range("D2"), Order3:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Excel Range
function Sort(Key1: OleVariant; Order1: XlSortOrder; Key2: OleVariant; Type_: OleVariant;
Order2: XlSortOrder; Key3: OleVariant; Order3: XlSortOrder; Header: XlYesNoGuess;
OrderCustom: OleVariant; MatchCase: OleVariant; Orientation: XlSortOrientation;
SortMethod: XlSortMethod): OleVariant; dispid 880;
Any Help ?
怎样使用Range.Sort方法
procedure TDataModuleMyExcel.MySort;
var
DataRange:Range;
key1:OleVariant;
begin
ExcelWorksheet1.Activate;
DataRange:=ExcelWorksheet1.Range['A1','A1'].CurrentRegion;
DataRange.Select;
//Key1:='Range("M2")';
TvarData(Key1).VType:=varDispatch;
TvarData(Key1).VDispatch:='Range("A2")';
DataRange.Sort(key1,xlDescending,
Emptyparam,Emptyparam,Emptyparam,Emptyparam,Emptyparam,
xlGuess,1,False,xlTopToBottom,xlPinYin);
运行时报错
vba宏如下
{' cbsok 记录的宏 2004-6-3
Selection.Sort Key1:=Range("A2"), Order1:=xlDescending,Header:=xlGuess,_
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom,SortMethod_
:=xlPinYin, DataOption1:=xlSortTextAsNumbers}
查到的资料
IRange
function Sort(Key1: OleVariant; Order1: XlSortOrder; Key2: OleVariant; Type_: OleVariant;
Order2: XlSortOrder; Key3: OleVariant; Order3: XlSortOrder; Header: XlYesNoGuess;
OrderCustom: OleVariant; MatchCase: OleVariant; Orientation: XlSortOrientation;
SortMethod: XlSortMethod; out RHS: OleVariant): HResult; stdcall;
Excel Macro
Selection.Sort Key1:=Range("B2"), Order1:=xlAscending, Key2:=Range("C2") _
, Order2:=xlAscending, Key3:=Range("D2"), Order3:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Excel Range
function Sort(Key1: OleVariant; Order1: XlSortOrder; Key2: OleVariant; Type_: OleVariant;
Order2: XlSortOrder; Key3: OleVariant; Order3: XlSortOrder; Header: XlYesNoGuess;
OrderCustom: OleVariant; MatchCase: OleVariant; Orientation: XlSortOrientation;
SortMethod: XlSortMethod): OleVariant; dispid 880;
Any Help ?