Ask Your Question
0

Macro to get default template location [closed]

asked 2016-10-01 10:38:15 +0200

Mr Spock gravatar image

I have been trying to find the correct macro syntax to get the default template folder location ie: the path setting in Options > LibreOffice > Paths > Templates

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Mr Spock
close date 2016-10-03 10:00:46.023360

3 Answers

Sort by » oldest newest most voted
0

answered 2016-10-01 10:48:41 +0200

JohnSUN gravatar image

I think you mean something like

MsgBox Join(Split(createUnoService("com.sun.star.util.PathSettings").Template,";"),Chr(10))
edit flag offensive delete link more
0

answered 2016-10-01 11:04:38 +0200

pierre-yves samyn gravatar image

Hi

There may be several paths defined. They are available as character string in the Template property. You get the default path in the property Template_writable:

dim oContext as object

oContext = GetDefaultContext.getByName("/singletons/com.sun.star.util.thePathSettings")
print oContext.Template
print oContext.Template_writable

Regards

edit flag offensive delete link more
0

answered 2016-10-01 13:35:36 +0200

Mr Spock gravatar image

Thank you both JohnSUN and pierre-yves samyn.

You have pointed me in the right direction

Here is my test code:

Sub PathTesting
Dim oSettings as Object
dim oContext as object
Dim sTemplate as String
Dim sTempFolder as String

    oSettings = createUnoService("com.sun.star.util.PathSettings")
    oContext = GetDefaultContext.getByName("/singletons/com.sun.star.util.thePathSettings")

    sTemplate = oSettings.template_writable
    sTempFolder = oContext.temp_writable

    msgbox "Templates: " & sTemplate & chr(13) & "Temp Folder: " & sTempFolder

End Sub

Here is why I am having difficulty getting my head around LO Basic. Both createUnoService("com.sun.star.util.PathSettings") and GetDefaultContext.getByName("/singletons/com.sun.star.util.thePathSettings") give the same results. Which one to use? I will be including some macro code in a document I want to distribute to numerous users. I want it to be as bullet proof as possible. Will either command work with all versions of Libre Office?

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-10-01 10:38:15 +0200

Seen: 123 times

Last updated: Oct 01 '16