Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Start Excel Workbook with Delphi 7 1

Status
Not open for further replies.

446421

Programmer
Jan 27, 2003
2
MA
Hi,

I have the following problem:
I use Delphi 7 and I simply want to start an Excel Workbook by clicking on a button. Everything I´ve tried so far hasn´t worked. I tried "ExecuteFile('E:\data\gcall.xls',,, SW_SHOW);" and "ShellExecute(nil,PChar('Open'),'E:\data\gcall.xls',nil,'',sw_show);".
Can anyone help ?
 
I got this to work. I include fmxutils.pas unit from C:\Program Files\Borland\Delphi6\Demos\Doc\Filmanex :



ExecuteFile('my.xls','','C:\Temp',sw_maximize); Brian
"There are 2 kinds of people in the world, those that divide people into two groups and those that don't. I belong to the second group." - tag line I stole
 
Here is a way for D5 users:

1. Add shellapi to the uses list.

2. Call ShellExecute.

Example:
[/code]
procedure TfrmMain.Button1Click(Sender: TObject);
begin
ShellExecute( 0, 'Open', '1.xls', '', 'C:\data\', SW_SHOW);
end;
[/code]
 
The fmxutils has been there for a while as well. I know it was there by Delphi 3, so you can probably find it on the same path, just substitute your version of delphi on the path. Saves you a couple parameters, and there are some other functions in there as well:

procedure CopyFile(const FileName, DestName: string);
procedure MoveFile(const FileName, DestName: string);
function GetFileSize(const FileName: string): LongInt;
function FileDateTime(const FileName: string): TDateTime;
function HasAttr(const FileName: string; Attr: Word): Boolean;
function ExecuteFile(const FileName, Params, DefaultDir: string;
ShowCmd: Integer): THandle;
Brian
"There are 2 kinds of people in the world, those that divide people into two groups and those that don't. I belong to the second group." - tag line I stole
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top