VBA Outlook Contacts problem

Discussion in 'Microsoft Outlook VBA Programming' started by michal_e, Jun 22, 2012.

  1. michal_e

    michal_e

    Joined:
    Jun 22, 2012
    Messages:
    1
    Likes Received:
    0
    Hi,

    I'm beginner in the VBA, so I know that it's could be silly problem, but I unfortunately I can't find any solution. I simply want to move every contacts from default folder ("Contacts") to another created be my (for example "Archive Contacts"). Its nessesary for me to run another script written by another person. So i write this:

    Sub copy_all()

    Dim NM As Outlook.Namespace
    Dim Oul As New Outlook.Application
    Dim currentItem As Object
    Dim currentContact As Outlook.ContactItem
    Dim contactFolder As Outlook.Folder
    Dim newFolder As Outlook.Folder




    Set NM = Oul.GetNamespace("MAPI")
    Set contactFolder = NM.Folders(1).Folders("Contacts")

    Set newFolder = contactFolder.Folders.Add("Moja_kopia_kontaktow")

    For Each currentItem In contactFolder.Items
    If (currentItem.Class = olContact) Then
    Set currentContact = currentItem

    currentContact.Move (newFolder)

    End If

    Next


    End Sub


    But I get error from Debugger that: "Object is required", I dont know what I'm doing wrong:(

    I would be very helpful for any advice and help
    Greets
     
    michal_e, Jun 22, 2012
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marc

    Vba mapping from Access 2002 fields to outlook 2002 (contacts) ?

    Marc, Feb 12, 2004, in forum: Microsoft Outlook VBA Programming
    Replies:
    1
    Views:
    411
    Ken Slovak - [MVP - Outlook]
    Feb 12, 2004
  2. Céline Brien

    VBA Outlook 2000 Delete contacts by categorie

    Céline Brien, Apr 13, 2004, in forum: Microsoft Outlook VBA Programming
    Replies:
    4
    Views:
    917
    Céline Brien
    Apr 15, 2004
  3. Guest

    Update Outlook Contacts on a Different Computer Using VBA

    Guest, Jun 22, 2004, in forum: Microsoft Outlook VBA Programming
    Replies:
    3
    Views:
    396
    Ken Slovak - [MVP - Outlook]
    Jun 23, 2004
  4. Guest

    delete a folder from my contacts in Outlook VBA

    Guest, Oct 7, 2005, in forum: Microsoft Outlook VBA Programming
    Replies:
    11
    Views:
    1,967
    Sue Mosher [MVP-Outlook]
    Oct 12, 2005
  5. Oliver Burkhardt

    How to access over VBA in Outlook 2003 contacts in other Datafiles?

    Oliver Burkhardt, Feb 20, 2007, in forum: Microsoft Outlook VBA Programming
    Replies:
    3
    Views:
    557
    Michael Bauer [MVP - Outlook]
    Feb 21, 2007
  6. Zaneb123

    VBA help with Contacts and Distribution lists in Outlook 2003

    Zaneb123, Jul 11, 2008, in forum: Microsoft Outlook VBA Programming
    Replies:
    1
    Views:
    337
    Michael Bauer [MVP - Outlook]
    Jul 15, 2008
  7. Mr. Cheeks

    can't access outlook contacts from excel via VBA

    Mr. Cheeks, Jun 9, 2009, in forum: Microsoft Outlook VBA Programming
    Replies:
    4
    Views:
    3,183
    Mr. Cheeks
    Jun 11, 2009
  8. KeenAs

    2003 Outlook Contacts - how do I add text to multiple contacts ....

    KeenAs, Aug 18, 2009, in forum: Microsoft Outlook VBA Programming
    Replies:
    2
    Views:
    324
    KeenAs
    Aug 27, 2009
Loading...