Open File function

Creating a macro - Writing a Script - Using the API

Open File function

Postby Peteron » Thu Jun 29, 2017 8:39 pm

I would like to insert a macro in my spreadsheet to open a folder /file. Effectively click on a cell and a picture opens up on screen.
Is this a feature of Open Office
Open Office v 4.1.3 running on Windows 10
Peteron
 
Posts: 4
Joined: Thu Jun 29, 2017 8:30 pm

Re: Open File function

Postby RoryOF » Thu Jun 29, 2017 8:46 pm

You can do this without a macro - /Insert /Hyperlink and point to the file; the system image viewer will open the picture, or change the Hyperlink to use the desired file viewer and the picture file and parameters on the file viewer command line.
Apache OpenOffice 4.1.3 on Xubuntu 16.04 (mostly 64 bit version) and infrequently on Win2K/XP
14 October 2016 was Pooh's 90th birthday
User avatar
RoryOF
Moderator
 
Posts: 25058
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Open File function

Postby Peteron » Thu Jun 29, 2017 9:37 pm

RoryOF wrote:You can do this without a macro - /Insert /Hyperlink and point to the file; the system image viewer will open the picture, or change the Hyperlink to use the desired file viewer and the picture file and parameters on the file viewer command line.


Thank you Rory. That answers the question and I have looked it up on the "Help". Unfortunately it might as well be written in Klingon . Alas I am a simple spreadsheet user and much of its secrets will always remain so.
Open Office v 4.1.3 running on Windows 10
Peteron
 
Posts: 4
Joined: Thu Jun 29, 2017 8:30 pm

Re: Open File function

Postby RoryOF » Thu Jun 29, 2017 10:24 pm

Peteron wrote:
RoryOF wrote:You can do this without a macro - /Insert /Hyperlink and point to the file; the system image viewer will open the picture, or change the Hyperlink to use the desired file viewer and the picture file and parameters on the file viewer command line.


Thank you Rory. That answers the question and I have looked it up on the "Help". Unfortunately it might as well be written in Klingon . Alas I am a simple spreadsheet user and much of its secrets will always remain so.


Some people have learned and speak Klingon; it's not impossible
.
Apache OpenOffice 4.1.3 on Xubuntu 16.04 (mostly 64 bit version) and infrequently on Win2K/XP
14 October 2016 was Pooh's 90th birthday
User avatar
RoryOF
Moderator
 
Posts: 25058
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Open File function

Postby robleyd » Fri Jun 30, 2017 3:42 am

it might as well be written in Klingon


Ask, and ye shall receive.

HeghDI' HYPERLINK Qap ngaS 'e' cell qar SoH click, SoQmoHbogh ghaH hyperlink.
optional celltext parameter SoH yIlo', url Sam, 'ej vaj bIngDaq ghItlh leghlu' mI' pagh cha' formula.

hyperlinked cell SoQmoHbogh ghaH je keyboard, cell, wIv press f2 Edit mode, 'el porghlaHDaj in front of hyperlink cursor, Shift + f10 press je, vaj 'eb Hyperlink DawIvpu'.
Cheers
David
OpenOffice 4.1.3 - Windows 7
OpenOffice 4.1.4 RC2 - Slackware 14.2 - 64 bit
User avatar
robleyd
Volunteer
 
Posts: 936
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Open File function

Postby Peteron » Fri Jun 30, 2017 3:39 pm

Well aren't you the clever one!!!!!!!!!!!!!!!
Open Office v 4.1.3 running on Windows 10
Peteron
 
Posts: 4
Joined: Thu Jun 29, 2017 8:30 pm

Re: Open File function

Postby robleyd » Sat Jul 01, 2017 2:04 am

You haven't said how you are having difficulty with the HYPERLINK function. In your case it seems it could be as simple as

Code: Select all   Expand viewCollapse view
=HYPERLINK("file:///C:/full/path/to/image.png")
Cheers
David
OpenOffice 4.1.3 - Windows 7
OpenOffice 4.1.4 RC2 - Slackware 14.2 - 64 bit
User avatar
robleyd
Volunteer
 
Posts: 936
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Open File function

Postby Peteron » Tue Jul 04, 2017 10:22 am

I have,following your advice managed to create the hyperlink and it works fine. I am still struggling with having that hyperlink in a cell as a "button". Otherwise the hyperlink runs into let's say 2 inches across the spreadsheet and looks terrible. Thanks for your help I am well on the way to doing what I am trying to do. Ta
Open Office v 4.1.3 running on Windows 10
Peteron
 
Posts: 4
Joined: Thu Jun 29, 2017 8:30 pm

Re: Open File function

Postby robleyd » Tue Jul 04, 2017 10:31 am

Then you may need to go to the next level of using the HYPERLINK function - utilise the second argument to replace the link itself with text of your choice.

So, utilising the guidance of F1 help, which shows the syntax as HYPERLINK("URL"; "CellText") we might use something like

Code: Select all   Expand viewCollapse view
=HYPERLINK("file:///C:/a/really/long/path/to/the/picture/soomewhere/in/the/filesystem/image.png";"Short text")


This will display Short text in the cell rather than the URL.

This is much like the example shown in the help

=HYPERLINK("file:///C:/writer.odt#Specification";"Go to Writer bookmark")displays the text Go to Writer bookmark, loads the specified text document and jumps to bookmark "Specification".
Cheers
David
OpenOffice 4.1.3 - Windows 7
OpenOffice 4.1.4 RC2 - Slackware 14.2 - 64 bit
User avatar
robleyd
Volunteer
 
Posts: 936
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia


Return to Macros and UNO API

Who is online

Users browsing this forum: Google [Bot] and 8 guests