When I start LO, I want it to autoload the first document in the Recent
Documents list. I have found no option to do this in LO itself, so I
tried to cobble together an LO Basic macro attached to application start
that does that. I googled and found a couple of posts that deal with
similar problems, so I tried to adapt those (mostly this post from 2008:
https://forum.openoffice.org/en/forum/viewtopic.php?t=7128 .)
The resulting macro attaches and is executed but it doesn't work. Now I
know almost nothing about LO (I'm a pretty new user), let alone its
macro language, but I'm a longstanding user of MS Office products and I
know their macro language fairly well.
This is my code:
Option Explicit
Sub Load1st()
Dim oCP, oCUA, oList, oItem As Object
Dim aProps(0) As New com.sun.star.beans.PropertyValue
oCP = GetProcessServiceManager().createInstanceWithContext( _
"com.sun.star.configuration.ConfigurationProvider", GetDefaultContext() )
aProps(0).Name = "nodepath"
aProps(0).Value = "/org.openoffice.Office.Common/History"
oCUA = oCP.createInstanceWithArguments( _
"com.sun.star.configuration.ConfigurationUpdateAccess", aProps )
oList = oCUA.getPropertyValue( "PickList" )
If oList.hasByName( "p0" ) Then
oItem = oList.getByName( "p0" )
If FileExists( oItem.URL ) Then
starDeskTop.loadComponentFromUrl(oItem.URL, "_blank", 0, Array())
End If
End If
End Sub
The macro borks at the access "oList.hasByName" which is not valid:
oList is an object so *something* does work but there's no hasByName
item.
Anyone got an idea?
Jon