Code: Select all
Sub showTemplateInfo(Optional pDoc As Object)
If IsMissing(pDoc) Then pDoc = ThisComponent
On Local Error Goto fail
MsgBox(templateInfo(pDoc))
Exit Sub
fail:
MsgBox("?No document!" )
End Sub
Sub showProfilePath()
MsgBox(userProfilePath())
End Sub
Function templateInfo(Optional pDoc As Object) REM Mainly for use in Calc formulas.
Dim tname As String, turl As String, out As String
If IsMissing(pDoc) Then pDoc = ThisComponent
turl = pDoc.DocumentProperties.TemplateURL
If turl="" Then turl = "<url missing>"
tname = pDoc.DocumentProperties.TemplateName
REM This is the name of the link shown by the template manager.
If tname="" Then tname = "<missing>"
out = turl & "?" & "name=" & tname
templateInfo _
= out
End Function
Function userProfilePath() REM For use in Calc e.g.
Dim substService As Object, out As String
substService = CreateUNOService("com.sun.star.util.PathSubstitution")
out = substService.getSubstituteVariableValue("$(user)")
userProfilePath _
= out
End Function