Last active
November 12, 2024 11:36
-
-
Save tdalon/e8a1ad22eacd63ee95730399189bafe2 to your computer and use it in GitHub Desktop.
Outlook VBA to copy a Meeting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See related blog post: https://tdalon.blogspot.com/2024/11/outlook-blocks-meeting-copy.html