Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hello,

if you want the folder of the current document, use ThisComponent.getURL()

Code Snippet:

Sub CurrentFolder()
 dim sCurFolder As String
 sCurFolder = ThisComponent.getURL()
 MsgBox "Current Folder: " & sCurFolder
End Sub

Hello,

if you want the folder of the current document, use ThisComponent.getURL()

Code Snippet:Snippet (obviously still some string manipulation required to make it useful for specific purposes)

Sub CurrentFolder()
 dim sCurFolder As String
 sCurFolder = ThisComponent.getURL()
 MsgBox "Current Folder: " & sCurFolder
End Sub

Hello,

if you want the folder of the current document, use ThisComponent.getURL() and ConvertFromURL

Code Snippet (obviously still some string manipulation required to make it useful for specific purposes)Snippet:

Sub CurrentFolder()
 dim sCurFolder sCurFolderURL As String
 sCurFolder dim sCurFolderSys As String
 sCurFolderURL = ThisComponent.getURL()
 sCurFolderSys = ConvertFromURL(sCurFolderURL)
 MsgBox "Current Folder: " & sCurFolder
sCurFolderSys
End Sub

Hello,

if you want the folder of the current document, use ThisComponent.getURL() and ConvertFromURL

Code Snippet:

Sub CurrentFolder()
 dim sCurFolderURL As String
 dim sCurFolderSys As String
 sCurFolderURL = ThisComponent.getURL()
 sCurFolderSys = ConvertFromURL(sCurFolderURL)
 MsgBox "Current Folder: " & sCurFolderSys
End Sub

Note: There is also a function CurDir, but I couldn't figure out, how to make a meaningful use of it, since on Windows I got the path to the installation of LibreOffice and on Linux I got my $HOME, regardless of the path to the current open document.

Hello,

if you want the folder of the current document, use ThisComponent.getURL() and ConvertFromURL

Code Snippet:Snippet: (still some string manipulation required)

Sub CurrentFolder()
 dim sCurFolderURL As String
 dim sCurFolderSys As String
 sCurFolderURL = ThisComponent.getURL()
 sCurFolderSys = ConvertFromURL(sCurFolderURL)
 MsgBox "Current Folder: " & sCurFolderSys
End Sub

Note: There is also a function CurDir, but I couldn't figure out, how to make a meaningful use of it, since on Windows I got the path to the installation of LibreOffice and on Linux I got my $HOME, regardless of the path to the current open document.

Hello,

if you want the folder of the current document, use ThisComponent.getURL() and ConvertFromURL

Code Snippet: Snippet 1: (still some string manipulation required)

Sub CurrentFolder()
 dim sCurFolderURL As String
 dim sCurFolderSys As String
 sCurFolderURL = ThisComponent.getURL()
 sCurFolderSys = ConvertFromURL(sCurFolderURL)
 MsgBox "Current Folder: Filename: " & sCurFolderSys
End Sub

Code Snippet 2: (shorter solution using "Tools" Library )

Sub CurrentFolder2()

 dim sPath as String

 GlobalScope.BasicLibraries.loadLibrary("Tools")  
 sPath = DirectoryNameoutofPath(ThisComponent.getURL(),"/")
 sPath = ConvertFromURL(sPath)
 MsgBox sPath

End Sub

Note: There is also a function CurDir, but I couldn't figure out, how to make a meaningful use of it, since on Windows I got the path to the installation of LibreOffice and on Linux I got my $HOME, regardless of the path to the current open document.

Hello,

if you want the folder of the current document, use ThisComponent.getURL() and ConvertFromURL

Code Snippet 1: (still some string manipulation required)

Sub CurrentFolder()
 dim sCurFolderURL As String
 dim sCurFolderSys As String
 sCurFolderURL = ThisComponent.getURL()
 sCurFolderSys = ConvertFromURL(sCurFolderURL)
 MsgBox "Current Filename: " & sCurFolderSys
End Sub

Code Snippet 2: (shorter solution using "Tools" Library )

Sub CurrentFolder2()

 GlobalScope.BasicLibraries.loadLibrary("Tools") 
 dim sPath as String

 GlobalScope.BasicLibraries.loadLibrary("Tools")  
 sPath = DirectoryNameoutofPath(ThisComponent.getURL(),"/")
 sPath = ConvertFromURL(sPath)
 MsgBox sPath

End Sub

Note: There is also a function CurDir, but I couldn't figure out, how to make a meaningful use of it, since on Windows I got the path to the installation of LibreOffice and on Linux I got my $HOME, regardless of the path to the current open document.

Hello,

if you want the folder of the current document, use ThisComponent.getURL() and ConvertFromURL

Code Snippet 1: (still some string manipulation required)

Sub CurrentFolder()
 dim sCurFolderURL CurrentFolder1()

 dim sCurFileURL As String
 dim sCurFileSys As String
 dim sFolderSys As String
 dim aPaths as Variant

 sCurFileURL = ThisComponent.getURL()
 sCurFileSys = ConvertFromURL(sCurFileURL)
 aPaths=Split(sCurFileSys,"\")

 For i = Lbound(aPaths) to Ubound(aPaths)-1
   sCurFolderSys As String
 sCurFolderURL = ThisComponent.getURL()
 = sCurFolderSys = ConvertFromURL(sCurFolderURL)
& aPaths(i)  & "/"
 Next i

 MsgBox "Current Filename: Pathname: " & sCurFolderSys
End Sub

Code Snippet 2: (shorter solution using "Tools" Library )

Sub CurrentFolder2()

 GlobalScope.BasicLibraries.loadLibrary("Tools") 
 dim sPath as String

 sPath = DirectoryNameoutofPath(ThisComponent.getURL(),"/")
 sPath = ConvertFromURL(sPath)
 MsgBox sPath

End Sub

Note: There is also a function CurDir, but I couldn't figure out, how to make a meaningful use of it, since on Windows I got the path to the installation of LibreOffice and on Linux I got my $HOME, regardless of the path to the current open document.

Hello,

if you want the folder of the current document, use ThisComponent.getURL() and ConvertFromURL

Code Snippet 1:

Sub CurrentFolder1()

 dim sCurFileURL As String
 dim sCurFileSys As String
 dim sFolderSys As String
 dim aPaths as Variant

 sCurFileURL = ThisComponent.getURL()
 sCurFileSys = ConvertFromURL(sCurFileURL)
 aPaths=Split(sCurFileSys,"\")

 For i = Lbound(aPaths) to Ubound(aPaths)-1
   sCurFolderSys = sCurFolderSys & aPaths(i)  & "/"
"\"
 Next i

 MsgBox "Current Pathname: " & sCurFolderSys
End Sub

Code Snippet 2: (shorter solution using "Tools" Library )

Sub CurrentFolder2()

 GlobalScope.BasicLibraries.loadLibrary("Tools") 
 dim sPath as String

 sPath = DirectoryNameoutofPath(ThisComponent.getURL(),"/")
 sPath = ConvertFromURL(sPath)
 MsgBox sPath

End Sub

Note: There is also a function CurDir, but I couldn't figure out, how to make a meaningful use of it, since on Windows I got the path to the installation of LibreOffice and on Linux I got my $HOME, regardless of the path to the current open document.