• Subject: MAPIFolder/ActiveX Excel cannot find Outlook folder
  • Author: Andy
  • Date: 05 Jul 2011
  • References:
Hi all, I'm having a rather annoying issue after some users have been updated to Office 2007 (from 2003) Their issue is with the below code, which seems to cause errors whether they already have Outlook open or not. The code below is from Excel, and uses Outlook to find the path to a certain public folder. It seems to be causing a "ActiveX component can't create object" issue. Using Resume Next it seems to work on most PC's but not all... It seems to fail on the Getfolder function because it can't find Outlook. All references are correct, no missing ones. Dim oOL As Outlook.Application On Error Resume Next Set oOL = GetObject("", "Outlook.Application") If Err.Number = 429 Then Err.Clear Set oOL = New Outlook.Application End If Set oFolder = GetFolder("Public Folders\All Public Folders \Guidance") etc.... Public Function GetFolder(strFolderPath As String) As MAPIFolder Dim objApp As Outlook.Application Dim objNS As Outlook.NameSpace Dim colFolders As Outlook.Folders Dim oFolder As Outlook.MAPIFolder Dim arrFolders() As String Dim i As Long On Error Resume Next strFolderPath = Replace(strFolderPath, "/", "\") arrFolders() = Split(strFolderPath, "\") Set objApp = Outlook.Application Set objNS = objApp.GetNamespace("MAPI") Set oFolder = objNS.Folders.Item(arrFolders(0)) If Not oFolder Is Nothing Then For i = 1 To UBound(arrFolders) Set colFolders = oFolder.Folders Set oFolder = Nothing Set oFolder = colFolders.Item(arrFolders(i)) If oFolder Is Nothing Then Exit For End If Next End If Set GetFolder = oFolder Set colFolders = Nothing Set objNS = Nothing Set objApp = Nothing End Function
05 Jul 2011MAPIFolder/ActiveX Excel cannot find Outlook folder.Andy
06 Jul 2011\ Re: MAPIFolder/ActiveX Excel cannot find Outlook folder.Andy
Contact Us
All times are in (US) Eastern Daylight Time (GMT -4:00)