Hallo,
ich mache gerade meine ersten Versuche mit COM, ich möchte (oder muß) alle Excel-Tabellen in einem Verzeichnis ausdrucken. Dazu habe ich zunächst folgenden Code geschrieben:
<small>
procedure TxlsDlg.PrnBtnClick(Sender: TObject);
var
FN : String;
i : Integer;
FWorkSheet : _Workbook;
begin
FExcel := CoExcelApplication.Create; { Deklaration: FExcel: _Application }
for i := 0 to FileListBox.Items.Count-1 do begin
FN := AddBackslash(FileListBox.Directory) + FileListBox.Items[i];
FExcel.Workbooks.Open(FN,
EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam,
0);
end;
FExcel.Visible[0] := true;
FWorkSheet := FExcel.Workbooks.Item[1];
FWorkSheet.PrintOut(EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam,
EmptyParam, 0);
end;
</small> <p>
Das ergibt die Fehlermeldung "CoInitialize wurde nicht aufgerufen". Woran liegt das?
Ist das Verfahren, das ich benutze überhaupt geeignet oder sollte man das anders lösen.
Vielen Dank für jeden Tip
ich mache gerade meine ersten Versuche mit COM, ich möchte (oder muß) alle Excel-Tabellen in einem Verzeichnis ausdrucken. Dazu habe ich zunächst folgenden Code geschrieben:
<small>
procedure TxlsDlg.PrnBtnClick(Sender: TObject);
var
FN : String;
i : Integer;
FWorkSheet : _Workbook;
begin
FExcel := CoExcelApplication.Create; { Deklaration: FExcel: _Application }
for i := 0 to FileListBox.Items.Count-1 do begin
FN := AddBackslash(FileListBox.Directory) + FileListBox.Items[i];
FExcel.Workbooks.Open(FN,
EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam,
0);
end;
FExcel.Visible[0] := true;
FWorkSheet := FExcel.Workbooks.Item[1];
FWorkSheet.PrintOut(EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam,
EmptyParam, 0);
end;
</small> <p>
Das ergibt die Fehlermeldung "CoInitialize wurde nicht aufgerufen". Woran liegt das?
Ist das Verfahren, das ich benutze überhaupt geeignet oder sollte man das anders lösen.
Vielen Dank für jeden Tip
Comment