I have tried using the following code to open a spreadsheet I have created in Excel. It runs, but a popup keeps coming up saying that my file has been deleted or moved. The file definitely still exists. I have tried creating new files with other names. none of them work.
procedure TForm1.Button1Click(Sender: TObject);
var
Excelfile: Variant;
Workbook: Variant;
begin
Excelfile := CreateOleObject('Excel.Application');
Workbook := Excelfile.workbooks.open('filename.xls');
end;
You should use a fully-qualified (absolute) path, not a relative path.
C:\Users\Andreas Rejbrand\Documents\Report.xls
Report.xls
(Indeed, if I'd ask you to go to the red cottage in Sweden, you'd certainly ask me about the precise address.)