Consulting

Results 1 to 7 of 7

Thread: Formula to extract Lotus Notes username

  1. #1
    VBAX Contributor Glaswegian's Avatar
    Joined
    Sep 2004
    Location
    Glasgow, Scotland
    Posts
    196
    Location

    Formula to extract Lotus Notes username

    Hi

    I'm looking at e-mailing from Excel using Lotus Notes (I know, but I have to work with what I've got) and have one problem.

    The code for Notes includes a line to parse the username to find the Notes Database name. However, the username does not appear correctly. The original line of code is
    username = session.username
    MailDbName = Left$(username, 1) & Right$(username, (Len(username) - InStr(1, username, " "))) & ".nsf"
    Stepping through the code shows that the username starts as

    CN=John Smith/OU=AB/O=XYZ_EUROPE

    The actual username within Notes should be

    John Smith/AB/XYZ_EUROPE

    and this is what I need to identify the user database.

    I'm not much good at formulae so I'd be grateful if anyone could suggest the changes required to end up with the correct username.

    Thanks.
    Iain - XL2010 on Windows 7

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Try

    =SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"CN=",""),"OU=",""),"O=",""
    )
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Contributor Glaswegian's Avatar
    Joined
    Sep 2004
    Location
    Glasgow, Scotland
    Posts
    196
    Location
    Hi xld

    Thanks.

    When I put your formula in the code I get a "Function not defined" message.
    MailDbName = Substitute(Substitute(Substitute(username, "CN=", ""), "OU=", ""), "O=", "") & ".nsf"
    No doubt something I've done or not done...
    Iain - XL2010 on Windows 7

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    When you said formula, I presumed that you meant Excel.

    In VBA, it would look like

    MailDbName = Replace(Replace(Replace(username, "CN=", ""), "OU=", ""), "O=", "")
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    VBAX Contributor Glaswegian's Avatar
    Joined
    Sep 2004
    Location
    Glasgow, Scotland
    Posts
    196
    Location
    Hi

    Apologies for not being clearer - that works great. Many thanks (as always).
    Iain - XL2010 on Windows 7

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by Glaswegian
    Hi

    Apologies for not being clearer - that works great. Many thanks (as always).
    I wasn't criticising Iain, just getting my excuses in for why I gave you a formula not VBA
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  7. #7
    VBAX Contributor Glaswegian's Avatar
    Joined
    Sep 2004
    Location
    Glasgow, Scotland
    Posts
    196
    Location
    Lol - no worries (I didn't think you were being critical anyway...)
    Iain - XL2010 on Windows 7

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •