Jump to content

Macros/ScriptForge/WhereIsLibOInstallFolderQuickwin

From The Document Foundation Wiki


How to to determine the LibreOffice installation folder

Authored by Jean-Pierre Ledure.

The loading of the ScriptForge Basic library can be done elsewhere. In Basic, all used variables are declared explicitly. The concerned code is presented inside a Basic Sub or a Python def.

Run that piece of code and consider the result.

Using the appropiate notation for system folders, the dialog show the installation folder.
Installation folder, according to current notation.

Code

REM		How to determine the LibreOffice installation folder ?
REM		Minimal required version: LibreOffice 7.6
REM 	Used service(s)	FileSystem

Sub DetermineFolder()
Dim fs As Object
Dim notation As String

	GlobalScope.BasicLibraries.loadLibrary("ScriptForge")
	fs = CreateScriptService("FileSystem")

	fs.FileNaming = "SYS"

	'	Normalize might improve the readability
	MsgBox fs.Normalize(fs.InstallFolder), title := "Notation = " & fs.FileNaming

	'	Variants:		HomeFolder
	'					ConfigFolder
	'					TemplatesFolder
	'	+ ... https://help.libreoffice.org/latest/en-US/text/sbasic/shared/03/sf_filesystem.html?&DbPAR=BASIC

End Sub
# coding: utf-8
from __future__ import unicode_literals

from scriptforge import CreateScriptService
basic = CreateScriptService('Basic')

###		How to determine the LibreOffice installation folder ?
###		Minimal required version: LibreOffice 7.6
### 	Used service(s)	FileSystem

def determinefolder():

	fs = CreateScriptService('FileSystem')

	fs.FileNaming = 'SYS'

	#	Normalize might improve the readability
	basic.MsgBox(fs.Normalize(fs.InstallFolder), title = 'Notation = ' + fs.FileNaming)

	#	Variants:		HomeFolder
	#					ConfigFolder
	#					TemplatesFolder
	#	+ ... https://help.libreoffice.org/latest/en-US/text/sbasic/shared/03/sf_filesystem.html?&DbPAR=BASIC


g_exportedScripts = (determinefolder,)

if __name__ == "__main__":
	determinefolder()

See also