Consulting

Results 1 to 3 of 3

Thread: Runtime error trying to create an Outlook SelectNamesDialog from Access

  1. #1

    Runtime error trying to create an Outlook SelectNamesDialog from Access

    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!

  2. #2
    i can not test, but it is possible that myolapp, needs to be visible or have a visible window, for the dialog to display

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    I have just tried it and the object instantiated just fine. I had Outlook 2013 running when I ran it, and was visible.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •