none
Word.GetAddress in Excel / The “Check Names” dialog displays in background RRS feed

  • Question

  • I am using the Word.GetAddress function in an Excel document to retrieve the first & last names of someone if he is in the GAL.

    From what I have understand, the only way to have the built-in "Check Names" dialog is to use the Word.GetAddress function.

    When the name entered matches more than entry, the "Check Names" displays but in the background. I have to Alt+Tab to get it.

    I have tried to use the "Activate" function or the "WindowsState" property to bring it upfront but I am stuck ...

    Function getFirstAndLastNames(pName As String) As String
        Dim oWord As Word.Application
        Dim strAddress  As String
    
        On Error GoTo getFirstAndLastNames_Error
    
        'If the search doesn't work, returns the argument
        getFirstAndLastNames = pName
    
        'Create the Word object to use GetAddress
        Set oWord = CreateObject("Word.Application")
    
        'Search
        strAddress = oWord.GetAddress(Name:=pName, CheckNamesDialog:=True, AddressProperties:="<PR_GIVEN_NAME> <PR_SURNAME>")
    
        'If there is a result, the function returns it
        If strAddress <> "" Then getFirstAndLastNames = strAddress
    
        'Quit Word
        oWord.Quit
    
        Set oWord = Nothing
    
        On Error GoTo 0
        Exit Function
    
    getFirstAndLastNames_Error:
    
        MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure getFirstAndLastNames of Module Test"
    
        If Not (oWord Is Nothing) Then oWord.Quit
    
    End Function



    I have seen this post (http://stackoverflow.com/questions/22508009/display-gal-in-excel-to-get-alias-or-email-adress) where there was a similar issue resolved but it doesn't say how ...

    Thanks in advance for your help.


    • Edited by abillon Friday, August 22, 2014 1:02 PM
    Friday, August 22, 2014 11:48 AM

Answers