troubleshooting Question

Error Wih GetNameSpace

Avatar of John Clingeleffer
John ClingelefferFlag for Australia asked on
Visual Basic ClassicMicrosoft Access
1 Comment1 Solution872 ViewsLast Modified:
Hello Experts,

The following code snippet (I have not included the whole function) runs from MS Access to text if a user can get to their Outlook inbox. Works across any Access from 2003 to 2010 and with any Outlook from 2003 to 2010. Which version of Access are combined with which versions of Outllok alsodoen't seem to matter as long as references point to the right Outlook version. On one computer (of hundreds) which has Access 2003 and Outlook 2010 the code fails at the highlighted GetNamespace line. Any ideas?


Dim outlookForceStarted As Boolean
Dim objOL As Outlook.Application
Dim oItem As Outlook.MailItem
Dim objNS As NameSpace
outlookForceStarted = False

On Error Resume Next

'see if Outlook is running
errMsg = "Error checking if Microsoft Outlook is running." & vbCrLf & vbCrLf & "A failure at this point can indicate a problem with your Microsoft Outlook installation of a missing VBA reference to the Outlook Object Library."
Set objOL = GetObject(, "Outlook.Application")
If Err <> 0 Then
    'Outlook wasn't running, so start it
    errMsg = "Error starting Microsoft Outlook."
    Set objOL = CreateObject("Outlook.Application")
    outlookForceStarted = True
End If
On Error GoTo mapiTestError

Set objNS = objOL.GetNamespace("MAPI")
Set objfolder = objNS.GetDefaultFolder(olFolderInbox)
Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros