Hi All. I have VBA code which I downloaded years ago and has been running trouble-free. It's triggered from a form control in a spreadsheet which attempts to create an appointment in one of a number of staff member's Outlook calendars.

Last week, something happened to permissions on all those calendars (result of some corporate changes) and the code was failing on an if condition. However, there were no errors being generated so it took me a long time to work out that it was a permissions error.

Here's a snippet of the code.

 Dim objApp As Outlook.Application
 Dim objNS As Outlook.Namespace
 Dim objFolder As Outlook.MAPIFolder
 Dim objDummy As Outlook.MailItem
 Dim objRecip As Outlook.Recipient
 Dim objAppt As Outlook.AppointmentItem
 Dim objOutlook As Object
 
'  A few lines of code here to set some variables for things like appointment time, duration etc..............

   If objRecip.Resolved Then  ' This has tested to make sure I have a valid recipient - I did have
        On Error Resume Next  ' Please note - I did try another option here which was a suggestion I saw and I changed this line to On Error GoTo 0 but that didn't produce anything??
        Set objFolder = objNS.GetSharedDefaultFolder(objRecip, olFolderCalendar) ' This sets a folder object to their calendar - this was working fine
        If Not objFolder Is Nothing Then
            Set objAppt = objFolder.Items.Add  ' this is then attempting to create an Appointment object.  The following If condition evaluated to false and therefore skipped the rest of the code that actually sets up all the appointment data
            If Not objAppt Is Nothing Then ' Need a better error check here to know that there was a permissions problem, not just skip to the Else/Endif
Can someone suggest either:

A way to test first to see if the user running the code does have permissions to create an appointment in the target calendar
or
A way to trap the error correctly and pop up an error message to inform the user that they don't have permission rather than the IF condition shown just evaluating to false.

Many thanks in advance.

David