[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libreoffice-users] Macro to autoload first recent doc


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

--
To unsubscribe e-mail to: users+unsubscribe@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted

Follow-Ups:
Re: [libreoffice-users] Macro to autoload first recent doc<sleeping.pillow@gmail.com>
Re: [libreoffice-users] Macro to autoload first recent doc<sleeping.pillow@gmail.com>
Re: [libreoffice-users] Macro to autoload first recent docJon Harringdon <jonathan.harringdon@virgin.net>
Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.