Value does not fall within the expected range.

Add-in Express™ Support Service
That's what is more important than anything else

Value does not fall within the expected range.
user errors on ConnectTo 
Wendi Taranto




Posts: 2
Joined: 2010-05-14
a few of my users get the following error:

Value does not fall within the expected range.
at AddinExpress.Outlook.IOutlookSecurityManager2.Connect(Object vTarget)
at AddinExpress.Outlook.SecurityManager.ConnectTo(Object outlookApp)


here is my code:

SecurityManager1 = New AddinExpress.Outlook.SecurityManager

Dim OlType As Type = Type.GetTypeFromProgID("Outlook.Application", False)

Try
gobjOutlook = System.Runtime.InteropServices.Marshal.GetActiveObject("Outlook.Application")
If (gobjOutlook Is Nothing) Then
goLog.LogActivity(10, "No active Outlook object", 2, 0, sProc)
End If
Catch
End Try

Try
If (gobjOutlook Is Nothing) Then
gobjOutlook = Activator.CreateInstance(OlType)
End If
Catch
End Try

If Not (gobjOutlook Is Nothing) Then
gobjMAPI = gobjOutlook.GetNamespace("MAPI")
gobjMAPI.Logon(strProfile, "", False, True)
SecurityManager1.ConnectTo(gobjOutlook)
SecurityManager1.DisableOOMWarnings = True

Else
goLog.LogActivity(10, "Could not create Outlook object", 2, 0, sProc)
Return False
End If


here is some additional information that might be important in finding a cause/solution...

"when they bought these three pcs they came with a preloaded (trial version) of MS Office 07...they had an IT company install office 03 over office 07..( since they owned office 03) After this he said they did have outlook problems..but they cleared up after a removal and a reinstall of 2003. Shawn stated that this was the only difference between the 3 new machines that are not working and the ones on the rest of the machines that do work."

all three users getting this error have machines that look like this:

Windows xp pro sp3
MS office outlook 2003 sp3
32 bit OS


i thought that maybe it had to do with some erroneous registry keys due to dual installation of outlook, but i don't see anything online to support this theory.

any ideas? suggestions?
Posted 14 May, 2010 10:05:37 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Wendi,

It is a bit strange issue. Looks like the gobjOutlook object is not valid. The ConnectTo method can accept the Outlook._Application or Outlook._Explorer or Outlook._Inspector interfaces as the parameter. Can you please try to test the following code (raw sketch):


        If Not (gobjOutlook Is Nothing) Then
            gobjMAPI = gobjOutlook.GetNamespace("MAPI")
            gobjMAPI.Logon(strProfile, "", False, True)

            Dim objExplorer As Outlook._Explorer = Nothing
            Dim objFolder As Outlook.MAPIFolder = gobjMAPI.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
            If Not (objFolder Is Nothing) Then
                Try
                    objFolder.GetExplorer(Type.Missing)
                Finally
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(objFolder)
                End Try
            End If

            If Not (objExplorer Is Nothing) Then
                Try
                    SecurityManager1.ConnectTo(objExplorer)
                    SecurityManager1.DisableOOMWarnings = True
                Finally
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(objExplorer)
                End Try
            End If

        Else
            goLog.LogActivity(10, "Could not create Outlook object", 2, 0, sProc)
            Return False
        End If


Please let me know about the results in any case.
Posted 14 May, 2010 11:02:29 Top
Wendi Taranto




Posts: 2
Joined: 2010-05-14
thanks dmitry. just received word on test results. error on this line:

Dim objFolder As Outlook.MAPIFolder = gobjMAPI.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)

Unable to cast COM object of type 'System.__ComObject' to interface type 'Outlook.MAPIFolder'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{00063006-0000-0000-C000-000000000046}' failed due to the following error: Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)).
Posted 18 May, 2010 08:40:00 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Wendi,

Thank you for the details. Most probably you have broken the Office installation on those PCs. Please try to repair or reinstall Microsoft Office completely.
Posted 18 May, 2010 09:35:17 Top