# Link to external files from Base

I am no database expert but Libre Office has made it straightforward for me to cobble together a simple 'names and addresses' style database which I use, among other things, for recording who has sent me Christmas Greetings. This is a straightforward 'Yes/No' field, of course. But people often send news about themselves and their families, which I would like to be able to refer to at some later date. I am happy to scan their letters to eg a .pdf file, in fact I will probably do that anyway, but it would be helpful if I could call up that file while looking at the relevant record in my database. And I would prefer to be able to access more than one file per record, because people might write to me more than once!

I think I am right in assuming that it is not a good idea to try to embed the files somehow - loading a lot of bitmaps seems very inefficient. But is there a way of linking from a record (eg 'Mike Smith') to 'Letter(s) from Mike Smith' which are stored on the same PC? If the answer to this query is easy, and explained in the literature, then I apologise!

edit retag close merge delete

Sort by » oldest newest most voted

A sample is attached for your convenience. There is just one for with a table grid & button. You simply select the wanted record and push the button. Only the first record will work because it is an internet link. The second two are for local files but need to be set for your choosing and are included because it isn't know what OS you are on. Record ID #1 is for Linux file location and ID #2 is for Windows. These will open automatically to the default programs in your system.

The process isn't difficult but requires a macro attached to the After record change event of the form. The only extra setting in the push button is in the properties General tab under Action - set this to Open document/web page. Finally the macro needs to change if your table column name or button name changes.

How you set all this in your DB is up to you. Maybe having a correspondence table linked to the mailing list. It would allow you as many records as wanted.

Sample: GetExternal.odb

Edit: Here is the macro (also in sample) but with areas to possibly change:

Sub InsertLocation
Dim oForm as Object
Dim oButton as Object
oform = thiscomponent.drawpage.forms.getbyname("NAME-OF-YOUR-FORM-HERE")
oButton = oform.PUSH-BUTTON-NAME-HERE
oButton.TargetUrl = oform.Columns.getbyname("COLUMN-NAME-HERE").getstring
End Sub

more