Skip to content

Instantly share code, notes, and snippets.

@tdalon
Last active November 12, 2024 11:36
Show Gist options
  • Save tdalon/e8a1ad22eacd63ee95730399189bafe2 to your computer and use it in GitHub Desktop.
Save tdalon/e8a1ad22eacd63ee95730399189bafe2 to your computer and use it in GitHub Desktop.
Outlook VBA to copy a Meeting
Sub Duplicate()
Dim Item As Object
Set Item = GetCurrentItem()
If Item Is Nothing Then
MsgBox "No Item selected"
Exit Sub
End If
If Not TypeOf Item Is Outlook.AppointmentItem Then
Exit Sub
End If
Dim myCopiedItem As Outlook.AppointmentItem
Set myCopiedItem = Item.Copy
' #TODO Does not work - not method to set property RecurrencePattern
If Item.IsRecurring Then
Dim RecPat As RecurrencePattern
Set RecPat = myCopiedItem.GetRecurrencePattern
Set srcRecPat = Item.GetRecurrencePattern
Set RecPat = srcRecPat
End If
myCopiedItem.Display
' TODO if user delete the item, it closes the window but does not delete it
End Sub
Function GetCurrentItem() As Object
Dim objApp As Outlook.Application
Set objApp = Application
On Error Resume Next
Select Case TypeName(objApp.ActiveWindow)
Case "Explorer"
Set GetCurrentItem = objApp.ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set GetCurrentItem = objApp.ActiveInspector.CurrentItem
End Select
Set objApp = Nothing
End Function
@tdalon
Copy link
Author

tdalon commented Nov 12, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment