PDA

View Full Version : Outlook Form - Show Current User



carlmf1987
07-18-2013, 07:16 AM
Hello

I am new to VBA (as of today!!) :)

Im triyng to show display the name of the "current user" that has a form opened in Microsoft Outlook. I want the name to be displayed in a text box on a form.

Basically, we use Outlook forms in public folders and the forms have a message page which is updated daily. If there are multiple people trying to save a form at the same time we all get conflict messages.

I want to show the current user on the form so we can all see if someone has the form open at the time we are trying to edit... if that makes sense :dunno


I have added the below code to Visual Basic:

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

What i do not know how to do is display the information on the form itself.

Sorry if i haven't explained this very well, i have never worked with this kind of thing before.

Thanks!!