Macro to Autoload Image URL per Field Text?

Discuss the database features
Post Reply
sdritchey
Posts: 7
Joined: Wed May 27, 2009 10:41 pm

Macro to Autoload Image URL per Field Text?

Post by sdritchey »

Hello all,

I'm looking to write a macro to autoload an image into a field based on the text in another field. To be more specific:

I have a plant ID database with scientific name, and a bunch of other information. I also have a folder with several images of each plant. The image files are named by the scientific name 1, scientific name 2, scientific name 3, etc. When I load the record I want the image fields to automatically look for the image file in a specified folder using the scientific name field as the first part of the file path, and then adding a 1, 2, or 3...

Could anyone break this macro down for a beginner like myself?

Or is it possible to do this by placing a URL path in the "default value" that somehow references the scientific name field and skip the macro?

Thanks,
Steve
OOo 3.1.X on Ms Windows XP
User avatar
TheGurkha
Volunteer
Posts: 6482
Joined: Thu Mar 13, 2008 12:13 pm
Location: North Wales, UK.

Re: Macro to Autoload Image URL per Field Text?

Post by TheGurkha »

Does this help: how to add images to base, with and without using path.

If this has answered your question please go to your first post and use the Edit button, and add [Solved] to the start of the title. You can use the green tick icon at the same time if you like.
Ubuntu 14.10 Utopic Unicorn, LibreOffice Version: 4.3.3.2
Gurkha Welfare Trust
sdritchey
Posts: 7
Joined: Wed May 27, 2009 10:41 pm

Re: Macro to Autoload Image URL per Field Text?

Post by sdritchey »

Hi Gurkha,

I was looking at that before I posted, but there's 2 things. Those macros were written before the 3.1 update, and now with 3.1 I can have a text field that stores the path and retrieves the images without the macro (scroll down to the bottom of the thread). I've got that up and running no problem. The other thing missing from that macro is the part that retrieves the text from the "scientific name" field and pastes that into the file path.

Thanks for the help,
Steve
OOo 3.1.X on Ms Windows XP
User avatar
TheGurkha
Volunteer
Posts: 6482
Joined: Thu Mar 13, 2008 12:13 pm
Location: North Wales, UK.

Re: Macro to Autoload Image URL per Field Text?

Post by TheGurkha »

I'm afraid I can't help further. Hopefully someone more experienced in this will come through this thread soon.
Ubuntu 14.10 Utopic Unicorn, LibreOffice Version: 4.3.3.2
Gurkha Welfare Trust
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Macro to Autoload Image URL per Field Text?

Post by Villeroy »

http://development.openoffice.org/releases/3.1.0.html
image controls: can be bound to text database columns, interpreting their content as relative link to the image i91310 feature-info:
Image controls in database forms can now be bound to text columns. Formerly, you could only bind them to columns whose content could reasonably be interpreted as binary (BLOB etc.). Now, when you select a text database column as source for the image control, then it will interpret the content of the respective column's content as URL, and load and display the image pointed to by this URL. Also, the URL might be relative to the document which the image control is embedded into.
Seemingly, the developers did not change the way how binary data (such as pictures) are handled. They just modified the image control to accept a text field. The text field is supposed to contain URLs as a pointer to picture files outside the database, relative to the Base document's path.
pics/holyday/beach.png
pics/dog/shit.bmp
pics/cat/scratch.jpg
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
RPG
Volunteer
Posts: 2250
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: Macro to Autoload Image URL per Field Text?

Post by RPG »

hello
I was looking at that before I posted, but there's 2 things. Those macros were written before the 3.1 update, and now with 3.1 I can have a text field that stores the path and retrieves the images without the macro (scroll down to the bottom of the thread). I've got that up and running no problem. The other thing missing from that macro is the part that retrieves the text from the "scientific name" field and pastes that into the file path.
You have only to point the data field from your image control to the field of your table which kept the name of the file. I knew people love macros but i"m afraid you can not use them in this case.

This all if I understand you correct.
Romke
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
Post Reply