Tuesday, April 2, 2013

removing "copy" from calendar appointments after importing calendar

Sometimes when importing a calendar into another Outlook calendar, most or all of the appointments will say "copy" before the appointment title.  A VB script that gives a fix is here:
http://answers.microsoft.com/en-us/office/forum/officeversion_other-outlook/importing-pst-outlook-calendars-subject-title-adds/c58ccd50-451d-4519-a1c9-f0d2491abba8

Recreated here for reference:

  1. Press Alt+F11 which will open the VBA window. 
  2. In the left pane, navigate to Project1-MS Outlook Object and double-click 'ThisOutlookSession'.
  3. Paste the code into the window in the right pane (code below)
  4. Press the green arrow button to execute the code.

Code to enter in step 3 (above):

Sub FixCopy()
Dim calendar As MAPIFolder
Dim calItem As Object
    
Set calendar = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderCalendar)
        
Dim iItemsUpdated As Integer
Dim strTemp As String

iItemsUpdated = 0
For Each calItem In calendar.Items
    If Mid(calItem.Subject, 1, 6) = "Copy: " Then
      strTemp = Mid(calItem.Subject, 7, Len(calItem.Subject) - 6)
      calItem.Subject = strTemp
      iItemsUpdated = iItemsUpdated + 1
    End If
    calItem.Save
Next calItem

MsgBox iItemsUpdated & " of " & calendar.Items.count & " Items Updated"

End Sub



No comments: