DoctorV3774
Programmer
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
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