PDA

View Full Version : [SOLVED:] Outlook - Apply VBA code to appointments when selected but not opened



JuliannaDemp
12-13-2021, 05:42 PM
I'd like to modify this vba code to run on appointments that are selected, but not opened.


Option Explicit
Sub InsertConfCallInfo()
Dim myItem As AppointmentItem
On Error GoTo lbl_Exit
Set myItem = ActiveInspector.CurrentItem
myItem.Location = "CALL: (866) 555-1212 / CODE: 9854101812"
'myItem.Display 'Not required as the item is already displayed.
lbl_Exit:
Exit Sub
End Sub

gmayor
12-15-2021, 09:52 PM
The following should work

Sub InsertConfCallInfo()
Dim myItem As AppointmentItem
On Error Resume Next
Select Case Outlook.Application.ActiveWindow.Class
Case olInspector
Set myItem = ActiveInspector.currentItem
Case olExplorer
Set myItem = Application.ActiveExplorer.Selection.Item(1)
End Select
myItem.Location = "CALL: (866) 555-1212 / CODE: 9854101812"
myItem.Save
lbl_Exit:
Set myItem = Nothing
Exit Sub
End Sub

JuliannaDemp
12-16-2021, 05:03 AM
It works! Thank you soooo much!