Use data in a field to open a link or file.
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.
Re:Use data in a field to open a link or file.
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 ;-)
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...
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