Topic: Open a pdf file
How can I pressing a button to open a pdf file ?
My Visual Database → General → Open a pdf file
How can I pressing a button to open a pdf file ?
Is this a PDF link saved in a database?
If it is the following code relies on Windows associating file types and will automatically open the correct program.
procedure frmMain_btnOpenPDF_OnClick (Sender: TObject; var Cancel: boolean);
var
fName :string;
begin
fName := SQLExecute('SELECT DISTINCT File_Filename FROM SomeTable WHERE id = '+frmMain.tgTable.SQLValue);
OpenFile(fName);
Alternatively if you only ever want to open a PDF file then the above becomes
var
fName :string;
begin
fName := SQLExecute('SELECT DISTINCT File_Filename FROM SomeTable WHERE id = '+frmMain.tgTable.SQLValue);
OpenFile(fName,'AcroRD32.exe');
If you are not getting the file name from a database link, just substitute the fName := with path and file name of the file you want opened. Obviously you could add in an OpenDialog if you want the user to search for a file or have an edit box for the user to fill out a name etc.
The file is not in the database. It is just a simply pdf file. I like to open it for a reason when i Press a command button
Hello v_pozidis
To simply open a file outside of the database , place this code behind a button and its event OnClick
OpenFile ('Z: \ WIP \ WIP.xls');
In this case, Excel will launch and open the WIP.xls file(and you know its path)
To make it more classy, you could use an OpenFile dialog box
JB
Use this on button on click button on click event
Openfile('filename.pdf');
My Visual Database → General → Open a pdf file
Powered by PunBB, supported by Informer Technologies, Inc.
Theme Hydrogen by Kushi