Libreoffice base requires an absolute url to display images

Hi, on Windows running LibreOffice 6.3.3.2, I have many tables with file names of images stored. These file names are all relative to specific directories. In a Form, I have used a button to display these images by passing the file name to a standard Windows Photo Viewer, but I can only get this to work if I specify an absolute Windows file path e.g. C:\d\libre\vol\dir1\image.jpg In my tables I would like to specify just the file name e.g. image.jpg, or at worst dir1\image.jpg I have tried putting these images in the paths specified in tools - options - libre office - paths, but I can’t get any of them to work. I just get a message saying " “image.jpg” is not an absolute URL that can be passed to an external application to open it".

Any ideas?
thanks

(revised question to example files)
Hi,
here is a test file that shows what I am doing. As you surmised, I compile the filename in TargetURL of the button. If I compile the complete absolute address in the button, clicking on the Button opens that file. If, on the other hand, I just specify the local filename, then I get the absolute address error. I haven’t included the images, you can add any images with the appropriate names to try out the logic, and adapt any absolute pathname.testShowImage.odb

Hello,

Actually not certain Base is the one requiring the absolute URL or if it is Windows Photo Viewer.

In Base when saving and displaying linked images, the relative path is what is stored. This can be used with the addition of the URL of the Base file. See answer here → Base - how to set image control to save url as relative or absolute path.

Now it appears in your case to be simply creating this string in the macro where you are calling the viewer:

myLocation = "C:\d\libre\vol\dir1\" & YOUR_RETRIEVED_FILE_NAME

Or you could store the relative location and use the method in the link. There are some other routines in the Tools library which may be of help.

Edit 2020-01-06:

As stated in the comment it is a matter of appending information.

In your sample posted the URL’s saved all start with:

file:///c:/d/libre/vol/000106/

and the macro you have is:

Sub insert_URL_in_Button(oEvent As Object)
	Dim oForm As Object
	Dim oButton As Object
	oForm = oEvent.Source
	oButton = oForm.btnShowImage
	oButton.TargetUrl = oForm.Columns.getByName("URL").getstring
End Sub

So if you only want to save xxx.jpg in the table field, your macro would be changed to:

Sub insert_URL_in_Button(oEvent As Object)
	Dim oForm As Object
	Dim oButton As Object
    Dim sURL AS String
	oForm = oEvent.Source
	oButton = oForm.btnShowImage
    sURL = "file:///c:/d/libre/vol/000106/" & oForm.Columns.getByName("URL").getstring
	oButton.TargetUrl = sURL
End Sub

And of course as noted there are many methods on what you can do or how to do this depending upon just what you want to save in the table record and what directories are to be utilized.

No, that is not what is happening, perhaps I haven’t explained clearly. I can put my images anywhere on my Windows machine, including the local path where Base is run, or My Documents or the LibreOffice working directory or any of the 10-12 addresses proposed by Base in the tools - options - libre office - paths. Wherever I put the images, though, whatever name or address I generate is always refused (unless it is absolute) by Base saying that “image.jpg” is not an absolute URL that can be passed to an external application to open it". So in my tables I am obliged to always put a full absolute address, which is quite strange. Windows programs don’t normally work like this, they will always look first in the list of addresses provided by the application. In Access for example I just used filenames without paths and then told Access what the current path was.Or perhaps I am doing something wrong somewhere, perhaps there is some hidden option somewhere that forces absolute addresses!

No hidden option to my knowledge.

So instead of continuing to guess as to how you are doing something, please explain what method you are using

to display these images by passing the file name to a standard Windows Photo Viewer

using a button. Even your comment is not clear as to when this error is generated - entry of data into the table or trying to display the image.

Edit:

So will take another guess here that you are moving the field name into the TargetUrl of the button. In this case I believe the absolute is needed. If this is the situation, again the same can be done here as mentioned in the answer. Have just tested without problem.

thanks again for your help. Very useful. best regards