Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trouble setting a default value for an Outlook Contacts Folder

Status
Not open for further replies.

DoctorV3774

Programmer
Oct 12, 2004
33
0
0
US
We have the following code on a button click below. User clicks the button cmdSelectFolder to invoke this function to browse and select a contacts folder which is then set here to
Me![txtFolderName].Value = pfld.Name. When we try and set a default value for Me![txtFolderName].Value to Sublog_Contacts we get an error because it seems as though the MAPI profile is not set right. How can we fix this so we can set a permanent default path and users do not have to browse? Thanks

Private Sub cmdSelectFolder_Click()

Call SelectFolder

End Sub

Function SelectFolder()

On Error GoTo ErrorHandler

Set appOutlook = CreateObject("Outlook.Application")
Set nms = appOutlook.GetNamespace("MAPI")

SelectContactFolder:
Set pfld = nms.PickFolder

Debug.Print "Default item type: " & pfld.DefaultItemType
If pfld.DefaultItemType <> olContactItem Then
'MsgBox "Please select a Contacts folder"
GoTo SelectContactFolder
End If

Forms![z_RFil5_frmCustom]![frmExportToOutlook].SetFocus
Me![txtFolderName].Value = pfld.Name

Me![LastContact].Value = ""

ErrorHandlerExit:
Exit Function

ErrorHandler:
MsgBox "Error No: " & Err.Number & "; Description: " & Err.Description
Resume ErrorHandlerExit

End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top