Board index » delphi » """I have a problem please help : - ("""

"""I have a problem please help : - ("""

        I am currently writing a small first time program and I have a
problem. All that I want to do is use a command button to open an external
application like MS Word, Excel etc. I have my command buttons all that I
need is the code for this

procedure TForm1.Button1Click(Sender: TObject);
begin

(I need to know what to put in here to launch an external application)

end;

This is all that i need to complete my first ever program. I would be very
grateful if any one could help me.

Please post help to shane...@globalnet.co.uk

Thanks In advance

    Shane Jones

 

Re:"""I have a problem please help : - ("""


Shane Jones heeft geschreven in bericht <7h6vr2$4o...@gxsn.com>...

Quote
>        I am currently writing a small first time program and I have a
>problem. All that I want to do is use a command button to open an external
>application like MS Word, Excel etc. I have my command buttons all that I
>need is the code for this

>procedure TForm1.Button1Click(Sender: TObject);
>begin

>(I need to know what to put in here to launch an external application)

>end;

>This is all that i need to complete my first ever program. I would be very
>grateful if any one could help me.

>Please post help to shane...@globalnet.co.uk

>Thanks In advance

>    Shane Jones

Hi,
I think this should do the trick:

procedure TForm1.Button1Click(Sender: TObject);
begin

ShellExecute(Application.MainForm.Handle, nil,
PChar('C:\the_dir_you_want\with_the_program_in_it\try_it.exe'),
Pchar(''), PChar('C:\the_dir_you_want\with_the_program_in_it'), SW_NORMAL);

end;

O yeah, don't forget to modify a few words at the USES point on top of the
page
change:

StdCtrls;

to:

StdCtrls, ShellApi;

That's it!!

enjoy
:)

greetz Eliminator

Other Threads