I'm having an issue getting some VB Script code to work. The code looks
like it should work but when the form is run and the command button is
clicked...I get no errors and the information is not filled in. I'm new
at CDO programming and some of this code has been taken from the net. If
there is someone willing to help me get this code working I would be in an
enormous debt to them. Here is a snippet of code to check out.
Function Item_Open()
'On Error Resume Next
End Function
Sub CommandButton1_Click()
' Create session
Set objSession = Application.CreateObject("MAPI.Session")
strRetCode =
objSession.Logon(Application.GetNameSpace("MAPI").CurrentUser, "", False,
False, 0)
' Get strUserName
strUserName = objSession.CurrentUser
' If strUserName not found
If Trim(strUserName) = "" Then
' Error creating session, show error message and exit
MsgBox "Undefinied error. Errorcode: " & strRetCode & ". Please contact
your System Administrator", 48, "Microsoft Outlook"
Item_Open = False
Else
strRetCode = "OK"
End If
' Get fields collection of the selected recipient object
Set objNewUser = objSession.CurrentUser
Set objNewFields = objNewUser.Fields
' We must reference each property as a single object in order
to pull
out the values
On Error Resume Next
Set objDisplayName = objNewFields.Item(CdoPR_DISPLAY_NAME)
Set objDepartment = objNewFields.Item(CdoPR_DEPARTMENT_NAME)
Set objManagerName = objNewFields.Item(CdoPR_MANAGER_NAME)
' Read all properties of the currently selected recipient
' IMPORTANT NOTE: If a particular property has no value it
must be set
to one space character,
' otherwise the update of all properties of the selected
recipient will
fail later
If objDepartment Is Nothing Then
Set objDepartment =
objNewFields.Add(CdoPR_DEPARTMENT_NAME," ")
End If
If objDisplayName Is Nothing Then
Set objDisplayName =
objNewFields.Add(CdoPR_DISPLAY_NAME," ")
End If
If objManagerName Is Nothing Then
Set objManagerNmae =
objNewFields.Add(CdoPR_MANAGER_NAME," ")
End If
' Put the properties into the apropriate fields on the form
Item.GetInspector.ModifiedFormPages("General").Controls("txtEmpName").Value
= objDisplayName.Value
Item.GetInspector.ModifiedFormPages("General").Controls("txtDepartment").Value
= objDepartment.Value
Item.GetInspector.ModifiedFormPages("General").Controls("txtEmpManager").Value
= objManagerName.Value
If you see any errors....please let me know. Again...any help is
extremely appreciated.
_________________________________________________________________
List posting FAQ: http://www.swinc.com/resource/exch_faq.htm
Archives: http://www.swynk.com/sitesearch/search.asp
To unsubscribe: mailto:[EMAIL PROTECTED]
Exchange List admin: [EMAIL PROTECTED]