Edit a calendar entry

Posted on 2012-08-20
Last Modified: 2012-08-22
Is it possible to run some VBA code that just after entering a calendar item look at the notes and do some text replacement?

For example if a user enters "John Smith - Blue Hats" for a given day we would like to replace "Blue Hats" with "BH"?

Thank you.
Question by:thandel
    LVL 28

    Expert Comment


    Using the ItemAdd event might be helpful.No Outlook here, so I can't provide a more detailed sample.

    This is similar to your request, except modify your calendar item instead of sending an email


    Author Comment

    Thanks similiar and perhaps useful but I'm not familiar with coding in Outlook so some sort of example specific to this question would be helpful for a successful solution.
    LVL 28

    Accepted Solution


    Private WithEvents Items As Outlook.Items
    Private Sub Application_Startup()
      Dim Ns As Outlook.NameSpace
      Set Ns = Application.GetNamespace("MAPI")
      Set Items = Ns.GetDefaultFolder(olFolderCalendar).Items
    End Sub
    Private Sub Items_ItemAdd(ByVal Item As Object)
      On Error Resume Next
    If Item.Class = olAppointment Then
        Item.Subject = Replace(Item.Subject, "Blue Hat", "BH")
       End If
    End Sub

    Open in new window


    Author Comment

    Great thanks... found the Items_ItemChange if the item is edited too.... thanks!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Find out how to use dynamic social media in email signatures with this top 10 DOs & DON’Ts.
    Create high volume marketing opportunities using email signatures with these top 10 DOs and DON'Ts of email signature marketing.
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
    This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now