Unanswered: Permission to access Outlook GAL from Access
I have the following code to retrieve a filtered list of names and email addresses from the MS Outlook GAL.
When I am stepping through the code I get prompted for permission to access the GAL on the line of code that retrieves the name, which is correct.
But when I am not stepping through the code I do not get the prompt and Access appears to hang. It's like Windows is waiting for me to respond to the prompt but I can't because it's not visible. (And no, it's not hiding behind another window)
Private Sub DirectoryButton_Click()
Const CDoPR_EMAILx = &H39FE001E
Dim mySMTP As String, myName As String
Dim cdoSession As New MAPI.Session
Dim cdoGAL As MAPI.AddressEntries
Dim q As Long
EmailListbox.RowSource = ""
EmailListbox.AddItem "Name" & ";" & "Email"
Set cdoSession = CreateObject("MAPI.session")
cdoSession.Logon , , False, False, 0
Set cdoGAL = cdoSession.AddressLists("Global Address List").AddressEntries
Set cdoFilter = cdoGAL.Filter
cdoFilter.Name = Me!Name
'On Error Resume Next
For q = 1 To cdoGAL.Count
' ***** This is where I should get the prompt to allow access to the GAL
myName = cdoGAL.item(q).Name
mySMTP = cdoGAL.item(q).Fields(CDoPR_EMAILx)
EmailListbox.AddItem myName & ";" & mySMTP
On Error GoTo 0
Set cdoGAL = Nothing
Set cdoSession = Nothing
I just found that it's a Windows problem. I use multiple monitors. When I have Access on the primary monitor I get the prompt. When I have Access on the secondary monitor I do not get the prompt and Access appears to hang.