Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Grab Open Outlook Username from Excel
I want to grab the users Outlook Email address while an Excel Macro is
running (and assuming Outlook is also running on the machine). Is there a quick and dirty way of doing this? If so, please point me in the right direction. Thanks! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Grab Open Outlook Username from Excel
Not so easy
See this site for code http://vbnet.mvps.org/ -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "jayklmno" wrote in message ... I want to grab the users Outlook Email address while an Excel Macro is running (and assuming Outlook is also running on the machine). Is there a quick and dirty way of doing this? If so, please point me in the right direction. Thanks! |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Grab Open Outlook Username from Excel
Figured it out for myself...
Sub DisplayCurrentUser() Dim myolApp As Outlook.Application Dim myNamespace As Outlook.Namespace Set myolApp = CreateObject("Outlook.Application") Set myNamespace = myolApp.GetNamespace("MAPI") MsgBox myNamespace.CurrentUser End Sub Only trouble is it prompts the Outlook Security pop box. "jayklmno" wrote: I want to grab the users Outlook Email address while an Excel Macro is running (and assuming Outlook is also running on the machine). Is there a quick and dirty way of doing this? If so, please point me in the right direction. Thanks! |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Grab Open Outlook Username from Excel
If you wanted to avoid the security prompt, a sneaky way to get the current
user name is to parse the text string in the name of the default mailbox. It would always (usually) contain the name of the person who is setup for that copy of Outlook. In this example, a Msgbox appears with the name of the current user. You would need to use Instr and/or Mid to parse out the actual person's name. Dim olApp As Outlook.Application Dim objNS As Outlook.NameSpace Application.StatusBar = "Checking For Existing Copy of Outlook..." ' test for instance of Outlook, exit if not able to start one On Error Resume Next Set olApp = GetObject(, "Outlook.Application") If Err.Number < 0 Then Set olApp = CreateObject("Outlook.Application") End If On Error GoTo 0 If olApp Is Nothing Then Application.StatusBar = False MsgBox "Cannot start Outlook. Please open Outlook and try again.", _ vbInformation Exit Sub End If Set objNS = olApp.GetNamespace("MAPI") Msgbox objNS.GetDefaultFolder(olFolderInbox).Parent Set objNS = Nothing Set olApp = Nothing End Sub On my system I would get a message box stating "Mailbox - Jimmy Pena" it would then be a simple matter of extracting my name from this string. This is "air code" from memory so you should proof it first before running. HTH, JP "jayklmno" wrote: Figured it out for myself... Sub DisplayCurrentUser() Dim myolApp As Outlook.Application Dim myNamespace As Outlook.Namespace Set myolApp = CreateObject("Outlook.Application") Set myNamespace = myolApp.GetNamespace("MAPI") MsgBox myNamespace.CurrentUser End Sub Only trouble is it prompts the Outlook Security pop box. "jayklmno" wrote: I want to grab the users Outlook Email address while an Excel Macro is running (and assuming Outlook is also running on the machine). Is there a quick and dirty way of doing this? If so, please point me in the right direction. Thanks! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to open Excel in different windows AND open from Outlook? | Setting up and Configuration of Excel | |||
How to get username during workbooks.open macro | Excel Programming | |||
excel open in outlook if outlook is running | Excel Discussion (Misc queries) | |||
Lookup an email address in Outlook based on Username (newbie quest | Excel Programming | |||
Using XL to grab current user's Outlook calendar item titles, dates, and durations? | Excel Programming |