Jonas Offersen
New Member
- Joined
- Feb 13, 2018
- Messages
- 14
Hi everyone, I'm okay with vba and excel, but I am a complete newbie with outlook.
I am trying to copy alle outlook.items from one calendar to another using this code. The copying works as intended but I get an error message when I try to use "if one item = the other item"... Does anyone here know what I am dong wrong?
All help is much appreciated!
PS! (I was not sure which forum to post this in, did I get it right? )
I am trying to copy alle outlook.items from one calendar to another using this code. The copying works as intended but I get an error message when I try to use "if one item = the other item"... Does anyone here know what I am dong wrong?
All help is much appreciated!
PS! (I was not sure which forum to post this in, did I get it right? )
Code:
For Each i In Outlook.Session.GetFolderFromID(TextBoxOrigin.Text).Items
If (Outlook.Session.GetFolderFromID(TextBoxDestination.Text).Items.Count <> 0) Then [COLOR=#00ff00]'if there is no items in the destination folder[/COLOR]
For Each i2 In Outlook.Session.GetFolderFromID(TextBoxDestination.Text).Items
If (i2 = i) Then [COLOR=#00ff00]'if origin item is in the destination folder < this is where i get the error.[/COLOR]
exist = True
End If
Next
Else
exist = False
End If
If exist = False Then
Dim myCopiedItem As Outlook.AppointmentItem
Dim myFolder As Outlook.Folder
Set myFolder = Outlook.Session.GetFolderFromID(TextBoxDestination.Text)
Set myCopiedItem = i.Copy
myCopiedItem.Move myFolder
End If
Next