Simplicty and flexibility!


Use data in a field to open a link or file.


Started by Bolt-on-Trailers
Search
You will need to Sign In to be able to add or comment on the forum!

Use data in a field to open a link or file.

Does anyone know if it is possible to use the field data as a link or to open a file or picture on your computer? For example could you use a button action to look at the data in Field1 = “C:\Users\jrains\Documents\Names.xlsx” to open the document Names.xlsx? I hope this makes sense. Any help would be greatly appreciated.


Written by Bolt-on-Trailers 21/03/17 at 18:36:07 DataEase 8.5 Runtime

Re:Use data in a field to open a link or file.

Download Sample



Hi.

It is much easier than you think ;-)

We have created a little example to show how you can do it (attached).

We use the function ExecuteFile() and luckily in modern windows you can "execute" a Docoument directly.

ExecuteFile("MyPdf.PDF") will open the PDF in the assigned Application ex. Acrobat Reader.

Depending on your security settings etc, it will just open or it will ask you if it is OK to open it.

However there is a small But..

When opening with a full path in WIndows the format used is different dependent on the path having spaces in it or not.

When it has Spaces the format is:

"d:\Documents\Bulgaria\Elena Hold House Unrestored\DSC00461.JPG"

When it doesn't have spaces the format is:

d:\Documents\Bulgaria\ElenaHoldHouseUnrestored\DSC00461.JPG

The stupid bit is that you can't use " " around the path if it DOESN'T have spaces in it (who defined this beauty?)

This is why our derivation looks like this:

ExecuteFile(if (StringFind(DocumentToOpen," ")>0,concat("/'",DocumentToOpen,"/'"),DocumentToOpen))


Here we use StringFind to check if there are spaces and if it is we concatenate the path with " " on each side. Lucky for us in 8.5 we have escape characters for forbidden characters like " which is /'.

To be "helpful" we have also shown how you can use DEOS to pick a file with the file explorer.

SetValue("DocumentToOpen",DEOS("@BrowseForFile"))+RefreshForm()


What we do here is to put the result from calling DEOS("@BrowseForFile") in the Field with objectname "DocumentToOpen" and then we call RefreshForm() to make sure the visual controls are updated to reflect this. 

Could it be simpler ;-)


Written by DataEase 21/03/17 at 19:35:24 DataEase 8.5 Runtime

Re:Re:Use data in a field to open a link or file.

I copied the elements into the form I am working on and it works great. This is extremely helpful and will make my work more productive. Thank you so much for your help and quick response...


Written by Bolt-on-Trailers 21/03/17 at 20:46:43 DataEase 8.5 Runtime

Re:Re:Use data in a field to open a link or file.

Can you only use this in 8.5 or will it work in 6.53 ? I have been trying for hours to get it working, in all different ways to open a file on the C:\ drive

that holds hundreds of pictures, C:\DEPics 


Written by Handles 10/03/22 at 19:29:24 DataEase 8.5 Runtime

Re:Re:Re:Use data in a field to open a link or file.

Sorted with              ShellExecuteA(0,"Open",PictureFile,"","",1)    and the field PictureFile has the name of the folder in it.... 


Written by Handles 10/03/22 at 20:30:29 DataEase 8.5 Runtime

Re:Re:Re:Re:Use data in a field to open a link or file.

There is certain elements in our example that will only work in DE8 onwards but obviously you can do almost anything with a little "elbow grease" in DE6 too as you have proven. 


Written by DataEase 11/03/22 at 10:50:26 DataEase 8.5 Runtime
DG3_ForumList