PDA

View Full Version : Runtime error trying to create an Outlook SelectNamesDialog from Access



glacialfury
01-03-2014, 06:53 PM
Hi - first time here, so be gentle! I've been trying unsuccessfully for two days to display the SelectNamesDialog from Access, and I'm running out of Google links/variations to try. I've narrowed the cause down to a failure to instantiate the SelectNamesDialog object, but I can't find a reason for the failure. Using similar code from within Outlook works fine. I can create MailItems etc from Access fine. I've tried it with Outlook open in the background and closed. I have the same issue whether at work (on Windows 7, using MS Office 2010) or at home (Windows 7, MS Office 2007).

I've simplified the code for testing:



Sub ShowSND()
Dim myOLApp As Outlook.Application
Dim myNS As Outlook.NameSpace
Dim mySND As Outlook.SelectNamesDialog

Set myOLApp = CreateObject("Outlook.Application")
Set myNS = myOLApp.GetNamespace("MAPI")
Set mySND = myOLApp.Session.GetSelectNamesDialog
End Sub


I receive a runtime error #287 (Application-defined or object-defined error). The program always stops on the line
Set mySND = myOLApp.Session.GetSelectNamesDialog, and the value of mySND remains "Nothing".

I'd appreciate any guidance on why this is happening. :-)

Thanks!

westconn1
01-10-2014, 06:04 AM
i can not test, but it is possible that myolapp, needs to be visible or have a visible window, for the dialog to display

Bob Phillips
01-19-2014, 11:02 AM
I have just tried it and the object instantiated just fine. I had Outlook 2013 running when I ran it, and was visible.