Consulting

Results 1 to 3 of 3

Thread: Outlook - Apply VBA code to appointments when selected but not opened

  1. #1

    Outlook - Apply VBA code to appointments when selected but not opened

    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
    Last edited by Aussiebear; 12-14-2021 at 04:54 PM. Reason: Added code tags to supplied code

  2. #2
    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
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  3. #3
    It works! Thank you soooo much!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •