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
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