[Solved] Hyperlink or shell macro from database

Discuss the database features
Post Reply
aceofjohnonline
Posts: 2
Joined: Sat Jun 20, 2015 6:54 am

[Solved] Hyperlink or shell macro from database

Post by aceofjohnonline »

Hi. I'm trying to create a database for my electrical components. one field 'datasheet' contains the location of a PDF file (http:// / file://) is it possible to have a macro that when i press a button called 'open' it will get the text value of 'datasheet' and open my default internet browser and pass the address as an argument. i have found some basic macro's that have mailto commands but i cant understand the macros and how they work so i cant modify them to work as a hyperlink. please can someone explain how I'm supposed to do this. i have spent hours searching but most of the hits are about other parts of open office and not base which makes finding information on the subject hard to find.

as a little bonus question... is it possible to run bat scripts or shell commands so i can open other file types that are not supported by my browser in a similar way.

Thank you for any help you offer.
Last edited by Hagar Delest on Sat Jul 25, 2015 7:26 pm, edited 1 time in total.
Reason: tagged solved
OpenOffice 4.1.1 on Windows 7
F3K Total
Volunteer
Posts: 1038
Joined: Fri Dec 16, 2011 8:20 pm

Re: Hyperlink or shell macro from database

Post by F3K Total »

Hi,
one way:
a Button has on it's General tab a property Action, which can be adjustet to Open Document / web page then URL becomes active.
The following Macro

Code: Select all

Sub S_insert_url_to_Button
    oform = thiscomponent.drawpage.forms.getbyname("MainForm")
    oButton = oform.cmdOpenFile
    oButton.TargetUrl = oForm.Columns.getbyname("URL").getstring
end sub
is attached to the structurals form (MainForm) event After Record change. It will always fill the Buttons URL-field with the text of the currently selected Row from Column URL of the forms datasource.
Find an example attached, having in addition a fileselection control with macro.
You can open files and hyperlinks.
R
Attachments
OpenHyperlinks.odb
(13.65 KiB) Downloaded 302 times
  • MMove 1.0.6
  • Extension for easy, exact positioning of shapes, pictures, controls, frames ...
  • my current system
  • Windows 10 AOO, LOLinux Mint AOO, LO
aceofjohnonline
Posts: 2
Joined: Sat Jun 20, 2015 6:54 am

Re: Hyperlink or shell macro from database

Post by aceofjohnonline »

Thank you F3K Total you are very helpful. this saves me a lot of messing about in the long run. much appreciated.
OpenOffice 4.1.1 on Windows 7
Jelle_
Posts: 1
Joined: Mon Jan 08, 2018 10:02 am

Re: [Solved] Hyperlink or shell macro from database

Post by Jelle_ »

Is there a possibility to use this code in a split database with several users on different types of machines?

I have adjusted the code that was given by F3K Total and it works perfect on my Windows machine and on my Apple machine. But, when I try to select a document on my Apple machine and save the link, my Windows machine can't open the file. They both use different kinds of URL's. The documents are saved on a share, so they can be entered by both machines.

Is there a solution for this problem?
LibreOffice 5.4.4.2 (x64) with Windows 7 Pro. MariaDB on Synology NAS
Post Reply