-1

I have a macro spreadsheet that I created in Windows which grabs the folder path that the spreadsheet is currently in, then opens a folder inside that directory.

I use the command shell ("C:\Windows\explorer.exe",1,FolderPath) where "FolderPath" is the string that has the final folder path to be opened. Is there an equivalent to this command in Linux, and whilst I am at it, MAC OS as well?

  • You are saying folders inside a directory which is probably not what you mean. Note that on Unix, BSD--and Linux, too--they are "directories" and not the Windows concept of "folders" which is not the same thing. – Rob Mar 27 '21 at 23:10
  • You'll have to forgive my lack of understanding of the nomenclature, as I am something of a novice at this. I had always understood "directory" and "folder" to be the same thing. Essentially, what I am trying to do here is open a target directory using the gui explorer, so the the user doesn't have to get there manually. Hope that clears things up. – LordSandwich Mar 28 '21 at 00:14
  • I still can't figure out what you are trying to achieve. No, it is clear that you need to open the file manager for the user, which is used in the current operating system, and show the user the contents of a specific folder (directory). But why? For what? What exactly should the user see (or vice versa - not see) in this new window? What will he have to do next? Click on one of the files to open it in the same LibreOffice? Something other? – JohnSUN Mar 28 '21 at 09:00

1 Answers1

1

First of all, find a way to find out which operating system your macro is running on (hint: look in Help)

Function OSName() As String
Dim keyNode As Object ' com.sun.star.configuration.ConfigurationAccess
    GlobalScope.Basiclibraries.LoadLibrary("Tools")
    keyNode = Tools.Misc.GetRegistryKeyContent("org.openoffice.Office.Common/Help")
    OSName = keyNode.GetByName("System")
End Function

Now you can use the commands specific to each of the systems:

...
    Select Case OSName
        Case "WIN"
            OpenCommand = "explorer"
        Case "MAC"
            OpenCommand = "open"
        Case "UNIX"
            OpenCommand = "xdg-open"
    End Select
    Shell (OpenCommand, 1, FolderPath)
...
JohnSUN
  • 2,268
  • 2
  • 5
  • 12