我下面的例子是使用Dll运行Excel中的一个宏,你可以参考参考。
-----------------------------------
library Transition1;
uses
Windows,SysUtils,Dialogs,Classes,Comobj,ADODB,Variants,Forms;
{$R *.res}
function Transition_ExcelFile(FileName:TFileName):Boolean;Stdcall;
var
ExcelApp,ExcelWorksheet,ExcelWorkbook:Variant;
begin
Result:=False;
Try
ExcelApp:=CreateOLEObject('Excel.Application');
ExcelWorkbook:=ExcelApp.WorkBooks.Open(ExtractFilePath(Application.ExeName)+'Transition.xls');
ExcelWorksheet:= ExcelApp.Worksheets['Cover'];
ExcelWorksheet.Activate;
ExcelWorkSheet.Cells[4,2]:=ExtractFileName(FileName);
ExcelApp.Run('Transition');
Result:=True;
finally
ExcelApp.Quit;
ExcelApp:=Null;
end;
end;
exports Transition_ExcelFile;
begin
CoInitializeex(nil,0);
end.