Excel and Outlook Calendars

J

J Streger

I am writing a procedure in VBA, in Excel that will pull the appointment
information from Outlook to Excel. What I also want to do is pull the account
name from Outlook, so I know who is working on the excel sheet, since not
everyone has set their properties the same. I can't find the command string
to get this string property. Does anyone know how or if this information can
be gleaned from an Excel macro? Thanks.
 
E

Eric Legault [MVP - Outlook]

If you want the full name of the user, use the NameSpace.CurrentUser
property. If you want the name of their Windows login account, use this code:

Public Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _
(ByVal lpBuffer As String, nSize As Long) As Long

Public Function FindUserName() As String

Dim strBuffer As String
Dim lngSize As Long

strBuffer = String(100, " ")
lngSize = Len(strBuffer)

If GetUserName(strBuffer, lngSize) = 1 Then
FindUserName = Left(strBuffer, lngSize)
Else
Exit Function
End If

'ELIMINATES NULL CHARACTERS
FindUserName = Replace(FindUserName, Chr(0), "")
End Function
 
Z

Zack Barresse

Windows User name, see the already given API call. Just username?

Environ("Username")

I would use this before I called a property from the Outlook Object Model
from within Excel. Personal preference.

HTH
 
Top