[Solved] Obtaining user name and initials

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
User avatar
Lazy-legs
Posts: 71
Joined: Mon Oct 08, 2007 1:33 am
Location: Århus-Berlin

[Solved] Obtaining user name and initials

Post by Lazy-legs »

Hello,

I'm back with one more OOo Basic-related question. Is there a way to obtain the user name and initials (those in Tools -> Options -> OpenOffice.org -> User Data) via a macro?

Thank you!

Kind regards,
Dmitri
Last edited by Lazy-legs on Wed Jul 02, 2008 10:05 am, edited 1 time in total.
hanya
Volunteer
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: Obtaining user name and initials

Post by hanya »

Hi,

You can get them from "/org.openoffice.UserProfile/Data" node of the configuration.

Code: Select all

Sub GetUserName()
  Dim oCP As Object
  Dim oCUA As Object
  Dim aProps(0) As New com.sun.star.beans.PropertyValue

  oCP = GetProcessServiceManager().createInstance( _
    "com.sun.star.configuration.ConfigurationProvider" )
  aProps(0).Name = "nodepath"
  aProps(0).Value = "/org.openoffice.UserProfile/Data"
  oCUA = oCP.createInstanceWithArguments( _
    "com.sun.star.configuration.ConfigurationUpdateAccess", aProps )
  
  sNames = oCUA.getPropertyValues( Array( "givenname", "sn", "initials" ) )
  
  msgbox "Given Name: " & sNames(0) & chr(10) & _
      "Family Name: " & sNames(1) & chr(10) & _
      "Initials: " & sNames(2) & chr(10)
  'msgbox oCUA.getByName("givenname")
  'msgbox oCUA.getByName("sn")
  'msgbox oCUA.getByName("initials")
End Sub
This may help you to get the name of them in the configuration.
http://wiki.services.openoffice.org/wiki/OoConfig
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
User avatar
Lazy-legs
Posts: 71
Joined: Mon Oct 08, 2007 1:33 am
Location: Århus-Berlin

Re: Obtaining user name and initials

Post by Lazy-legs »

Excellent! Than you.

Kind regards,
Dmitri
Post Reply