JeffGrant
Well-known Member
- Joined
- Apr 7, 2021
- Messages
- 558
- Office Version
- 365
- Platform
- Windows
Hi All,
in my model I have several subs that use the following code to send info from excel to various outlook calendars. Generally, it is not an issue. However, this week i have programmed something new that is sending multiple bits of information in short succession to outlook calendars in a short period of time. What I think is happening is that vba is throwing 462, server not available errors because there is confusion between creating a new outlook instance and using a current outlook exitance.
when clicking on Debug, the line Set olNs = olApp.GetNamespace("MAPI") is where the debugger goes.
If I am correct about the vb confusion between creating an outlook instance using the current outlook instance, i assume then I would have thought the If olApp test would have handled that and the olApp.Getnamespace would be fine. Clearly I am wrong,otherwise I would be getting the 462 error.
Can somebody please help me on this one.
Thank in advance.
This code is in 4 subs, although, I do suspect that one high volume sub is the culprit.
Dim olApp As Outlook.Application
Dim olAppt As Outlook.AppointmentItem
Dim blnCreated As Boolean
Dim olNs As Outlook.Namespace
Dim CalFolder As Outlook.MAPIFolder
Dim subFolder As Outlook.MAPIFolder
Dim arrCal As String
On Error Resume Next
Set olApp = Outlook.Application
If olApp Is Nothing Then
Set olApp = Outlook.Application
blnCreated = True
Err.Clear
Else
blnCreated = False
End If
On Error GoTo 0
Set olNs = olApp.GetNamespace("MAPI")
Set CalFolder = olNs.GetDefaultFolder(olFolderCalendar)
Set subFolder = CalFolder.Folders(arrCal)
Set olAppt = subFolder.Items.Add(olAppointmentItem)
in my model I have several subs that use the following code to send info from excel to various outlook calendars. Generally, it is not an issue. However, this week i have programmed something new that is sending multiple bits of information in short succession to outlook calendars in a short period of time. What I think is happening is that vba is throwing 462, server not available errors because there is confusion between creating a new outlook instance and using a current outlook exitance.
when clicking on Debug, the line Set olNs = olApp.GetNamespace("MAPI") is where the debugger goes.
If I am correct about the vb confusion between creating an outlook instance using the current outlook instance, i assume then I would have thought the If olApp test would have handled that and the olApp.Getnamespace would be fine. Clearly I am wrong,otherwise I would be getting the 462 error.
Can somebody please help me on this one.
Thank in advance.
This code is in 4 subs, although, I do suspect that one high volume sub is the culprit.
Dim olApp As Outlook.Application
Dim olAppt As Outlook.AppointmentItem
Dim blnCreated As Boolean
Dim olNs As Outlook.Namespace
Dim CalFolder As Outlook.MAPIFolder
Dim subFolder As Outlook.MAPIFolder
Dim arrCal As String
On Error Resume Next
Set olApp = Outlook.Application
If olApp Is Nothing Then
Set olApp = Outlook.Application
blnCreated = True
Err.Clear
Else
blnCreated = False
End If
On Error GoTo 0
Set olNs = olApp.GetNamespace("MAPI")
Set CalFolder = olNs.GetDefaultFolder(olFolderCalendar)
Set subFolder = CalFolder.Folders(arrCal)
Set olAppt = subFolder.Items.Add(olAppointmentItem)