[Solved] Macro to open an operating system folder on Mac

Creating a macro - Writing a Script - Using the API

[Solved] Macro to open an operating system folder on Mac

Postby JuanPa » Fri Mar 26, 2021 3:00 pm

Hi.
I'm doing this macro for Base, but it doesn't work and I can't find specific information for Mac.
The purpose is to open the stored folder (not a file).
Does "explorer" really work on Mac too?

Code: Select all   Expand viewCollapse view
Sub ShowFolder (Evento)
Dim oForm As Object
Dim Folder As String
Dim oPathLink as String
Dim oPahtOS as String

   oForm = Evento.Source.Model.Parent
   Folder= oForm.GetByName("Location").Text
   GlobalScope.BasicLibraries.LoadLibrary("Tools")   
   oPathOS = ConvertFromURL(Folder)
   Shell "explorer " & oPathOS

End Sub


How could I make it work?
Last edited by Hagar Delest on Sat Mar 27, 2021 5:44 pm, edited 1 time in total.
Reason: tagged solved.
Open Office 4.1.9
macOS 11.2.3
JuanPa
 
Posts: 2
Joined: Fri Mar 26, 2021 2:48 pm

Re: Will this macro work on mac?

Postby Villeroy » Fri Mar 26, 2021 3:16 pm

Try finder instead of explorer.
Where does the event object come from?
What are you trying to do? I can open a folder with a simple click on a hyperlink. If the folder exisits, it is shown in the system's prefered file manager.
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
User avatar
Villeroy
Volunteer
 
Posts: 29885
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Will this macro work on mac?

Postby robleyd » Sat Mar 27, 2021 12:00 am

You seem to have a typo:
Code: Select all   Expand viewCollapse view
Dim oPahtOS as String
....
oPathOS = ConvertFromURL(Folder)
Cheers
David
Apache OpenOffice 420m2(Build:9821) - Slackware 14.2 - 64 bit
LibreOffice 6.4.6.2 (SlackBuild for 6.4.6 by Eric Hameleers) - Slackware 14.2 - 64 bit
Apache OpenOffice 4.1.4 - Windows 7 Virtual machine
User avatar
robleyd
Moderator
 
Posts: 4026
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Will this macro work on mac?

Postby Zizi64 » Sat Mar 27, 2021 8:05 am

Code: Select all   Expand viewCollapse view
Dim oPahtOS as String
....
oPathOS = ConvertFromURL(Folder)


Use the

Code: Select all   Expand viewCollapse view
Option Explicit

directive at start of the code in a Module. Then the interpreter will warn you if a variable is not Dimensioned, or when there is a typo in the name inside the sub (when the used name is not same as the dimensioned one).
Tibor Kovacs, Hungary; LO6.1.6, 6.4.7 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.1.1;AOO4.1.9
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 9882
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Will this macro work on mac?

Postby Villeroy » Sat Mar 27, 2021 3:56 pm

The easy way to open files, mails and any other URLs with a push button: viewtopic.php?t=98542&p=473296#p473296
This ivolves a one-click macro install, a button with a little extra, a query and the form being assigned to a macro (not a control). No code editing required.

If you need to open some directory with a button:
Create a query like:
Code: Select all   Expand viewCollapse view
SELECT *, '/path/' || "DirName" AS "Path" FROM "MyTable"
as the source of your form. The query returns the complete "MyTable" plus a "Path" field with the concatenated paths. "MyTable" is the name of your table and "DirName" is the name of the column with the directory names. /path/ is the hardcoded path leading to the specified directory in system notation (would be like D:\Path\ under Windows). Use this form with this source together with the FileButton_Approve macro assigned to the form's approve event. This macro includes a conversion from system notation to a file-URL which is assigned to the push button when the underlying record has changed.
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
User avatar
Villeroy
Volunteer
 
Posts: 29885
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Will this macro work on mac?

Postby JuanPa » Sat Mar 27, 2021 4:48 pm

Thanks for all the answers. Finally this is the code I have used:

Code: Select all   Expand viewCollapse view
Sub ShowFolder(Evento)
Dim oForm As Object
Dim Folder As String

   oForm = Evento.Source.Model.Parent
   Folder= oForm.GetByName("Location").Text
 
   Shell "open " & Folder

End Sub


I changed "explorer" to "open" and it works fine!

Thanks!
Open Office 4.1.9
macOS 11.2.3
JuanPa
 
Posts: 2
Joined: Fri Mar 26, 2021 2:48 pm


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 9 guests