2013/9/29 Bernard Marcelly <[email protected]> > Message de Johnny Rosenberg date 2013-09-28 17:03 : > > >> Is there a similar way to get the folder name directly? I couldn't find it >> > > Not directly. But you can use a routine from the Tools library: > > Dim docFolder As String > > GlobalScope.BasicLibraries.loadLibrary("Tools") > docFolder = DirectoryNameoutofPath(ThisComponent.URL, "/") > MsgBox(docFolder, 0, "Folder of this document") >
Thanks, that will be good enough. > > And, referring to your code, you don't need to ConvertToURL() what is > already an URL address ;-) > Good, because I didn't. I converted FROM URL, not TO. :P ThisComponent.getURL() returns (for instance) ”file:///a/b%20c/d.e” and I want ”/a/b c/d.e”, and that's what ConvertFromURL() does for me. My code was not complete, I only brought the part relevant for my question. What's going to happen with my path is that I'm going to use it to run a Bash script from the macro, for instance Shell(MyCommand, 4, Parameters). MyCommand could be something like "/home/guraknugen/bin/SomeFancyScript.sh". In this particular case the script is located in the same folder as the spreadsheet itself, that's why I want the folder name of the spreadsheet. For instance: SpreadsheetFilename="/home/guraknugen/some/folder/MySpreadsheet.ods" FolderName="/home/guraknugen/some/folder" ' Maybe using that DirectoryNameOutOfPath() method ScriptName=FolderName & "/DoThisAndThat.sh" I always (well, almost always) organise my files and folders project-wise. I don't have a folder with all my spreadsheets etc, because it just doesn't make sense to me. It makes more sense to keep files that belong to the same ”project” together. Could be a spreadsheet, some images, maybe a couple of sound files etc, organised in sub-folders to the project's folder. If I want to see all my spreadsheets on the whole drive, I could always search for .ods files in my home folder and its sub-folders. There could be a point collecting all scripts at one place, but I can achieve that with symbolic links. Anyway, I think those Tools will be useful. Thanks for your help! Johnny Rosenberg > > Regards > Bernard > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >
