Question : Macro to export outlook contacts to Excel hangs

I am writing a macro that exports Outlook contacts to Excel. However, although the values are returned to the screen, the program just "hangs" at the very end i.e no control is passed back to the user.

Can anybody see why ? The code is given below. Thanks

Kaps
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
Private Sub Cmd_Retrieve_Contacts_Click()
 
'Retrieves contacts from Outlook
'and writes them to Excel Workbook
 
    Dim olApp As Outlook.Application
    Dim olNs As Namespace
    Dim Fldr As MAPIFolder
    Dim olCi As ContactItem
    
    Dim Top_Left_Corner As Range
    Dim row As Long
    
    Set olApp = New Outlook.Application
    Set olNs = olApp.GetNamespace("MAPI")
    Set Fldr = olNs.Folders("Personal Folders").Folders("Contacts")
 
    Set Top_Left_Corner = Sheets("Mail Merge").Range("Top_Left")
     
    row = 1
    For Each olCi In Fldr.Items
    
      With Top_Left_Corner.Offset(row, 1)
        .Value = olCi.FullName
      End With
      
      With Top_Left_Corner.Offset(row, 2)
         .Value = olCi.Email1Address
      End With
      
      
      row = row + 1
     
    Next olCi
 
    Set olCi = Nothing
    Set Fldr = Nothing
    Set olNs = Nothing
    Set olApp = Nothing
 
End Sub

Answer : Macro to export outlook contacts to Excel hangs

Hello KapTheHat,

If it's a permission issue, you may want to look at these three products:

1) Express ClickYes
http://www.contextmagic.com/express-clickyes/
There is a free version and a Pro version for ~$30 with more features.  I've used the pro version.
It works as advertised.  I'm not using it currently.  I'm using the MAPILab product instead.

2) MAPILab Advanced Outlook Security
http://www.mapilab.com/outlook/security/
A free COM add-in for Outlook.  I am using it now and I like it

3) Redemption
http://www.dimastr.com/redemption/
A DLL you can use in your code to disable the warnings.  Free download, but you must pay a
license to distribute.  I've used it and like it.


Regards,

Patrick
Random Solutions  
 
programming4us programming4us