A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

How can I pull current user info into a custom outlook form?



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old September 27th 07, 09:01 PM posted to microsoft.public.outlook.program_vba
Jenn
external usenet poster
 
Posts: 22
Default How can I pull current user info into a custom outlook form?

I am creating a custom form in Outlook and would like to pull in the current
Users Manager's name. Any suggestions on where I go to find some code to
accomplish that?
Ads
  #2  
Old September 27th 07, 09:18 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default How can I pull current user info into a custom outlook form?

You'd need to use code behind the form to set the value of the desired property to the string returned by Application.Session.CurrentUser.Manager. If you need a primer on working with Outlook properties, see http://www.outlookcode.com/article.aspx?ID=38

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Jenn" wrote in message ...
I am creating a custom form in Outlook and would like to pull in the current
Users Manager's name. Any suggestions on where I go to find some code to
accomplish that?

  #3  
Old September 27th 07, 11:35 PM posted to microsoft.public.outlook.program_vba
Mark J. McGinty
external usenet poster
 
Posts: 56
Default How can I pull current user info into a custom outlook form?


"Jenn" wrote in message
...
I am creating a custom form in Outlook and would like to pull in the
current
Users Manager's name. Any suggestions on where I go to find some code to
accomplish that?



If by that you mean the user that's currently logged in to Windows, this
will do it in VB6:


Private Declare Function WNetGetUser Lib "mpr.dll" Alias "WNetGetUserA"
(ByVal lpName As String, ByVal lpUserName As String, lpnLength As Long) As
Long

Function GetLoggedInUser() As String

Dim UserName As String, Ln As Long
UserName = String$(1024, 0)
Ln = 1023
WNetGetUser vbNullString, UserName, Ln
GetLoggedInUser = UserName

End Function



-Mark


  #4  
Old September 28th 07, 03:24 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default How can I pull current user info into a custom outlook form?

Form code (VBScript) can't use Win32 API functions.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Mark J. McGinty" wrote in message
...

"Jenn" wrote in message
...
I am creating a custom form in Outlook and would like to pull in the
current
Users Manager's name. Any suggestions on where I go to find some code to
accomplish that?



If by that you mean the user that's currently logged in to Windows, this
will do it in VB6:


Private Declare Function WNetGetUser Lib "mpr.dll" Alias "WNetGetUserA"
(ByVal lpName As String, ByVal lpUserName As String, lpnLength As Long) As
Long

Function GetLoggedInUser() As String

Dim UserName As String, Ln As Long
UserName = String$(1024, 0)
Ln = 1023
WNetGetUser vbNullString, UserName, Ln
GetLoggedInUser = UserName

End Function



-Mark


  #5  
Old September 28th 07, 07:29 PM posted to microsoft.public.outlook.program_vba
Mark J. McGinty
external usenet poster
 
Posts: 56
Default How can I pull current user info into a custom outlook form?


"Ken Slovak - [MVP - Outlook]" wrote in message
...
Form code (VBScript) can't use Win32 API functions.


In that case:

Set WshNetwork = CreateObject("Wscript.Network")
UserName = WshNetwork.UserName


-Mark




Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Mark J. McGinty" wrote in message
...

"Jenn" wrote in message
...
I am creating a custom form in Outlook and would like to pull in the
current
Users Manager's name. Any suggestions on where I go to find some code to
accomplish that?



If by that you mean the user that's currently logged in to Windows, this
will do it in VB6:


Private Declare Function WNetGetUser Lib "mpr.dll" Alias "WNetGetUserA"
(ByVal lpName As String, ByVal lpUserName As String, lpnLength As Long)
As Long

Function GetLoggedInUser() As String

Dim UserName As String, Ln As Long
UserName = String$(1024, 0)
Ln = 1023
WNetGetUser vbNullString, UserName, Ln
GetLoggedInUser = UserName

End Function



-Mark




  #6  
Old September 28th 07, 08:26 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default How can I pull current user info into a custom outlook form?

That would work.

Unless of course something like a script stopper prevents instantiating
scripting objects.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Mark J. McGinty" wrote in message
...

"Ken Slovak - [MVP - Outlook]" wrote in message
...
Form code (VBScript) can't use Win32 API functions.


In that case:

Set WshNetwork = CreateObject("Wscript.Network")
UserName = WshNetwork.UserName


-Mark


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I pull active directory information into an outlook form? jcross Outlook - Using Forms 4 April 25th 07 09:10 PM
User cant pull up their contact's list when they try and send an e ithandyman Outlook - Using Contacts 1 August 14th 06 10:29 PM
Emailing a contact vCard with custom form loses all custom info Kim Outlook - Using Contacts 7 April 27th 06 01:21 AM
Insert into a new e-mail form user defined info from tasks Logistics Masters Outlook - Using Forms 1 March 20th 06 09:25 PM
One user experiencing slow loading time for Custom Form [email protected] Outlook - Using Forms 0 March 9th 06 06:03 AM


All times are GMT +1. The time now is 08:36 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.