Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 405
  • Last Modified:

Edit a calendar entry

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.
0
thandel
Asked:
thandel
  • 2
  • 2
1 Solution
 
Michael PfisterCommented:
http://msdn.microsoft.com/en-us/library/aa155701(v=office.10).aspx#odc_ch11olevents_topic6

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

http://www.slipstick.com/outlook-developer/send-email-when-you-add-appointment-to-calendar/

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

HTH.
0
 
thandelAuthor Commented:
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.
0
 
Michael PfisterCommented:
Try

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")
    Item.Save
   End If

End Sub

Open in new window

0
 
thandelAuthor Commented:
Great thanks... found the Items_ItemChange if the item is edited too.... thanks!
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now