Hi everybody and thx to read my post (and my poor english).
I Just created a macro in order to :
1) check if an appoitment (by subject) is currently existing in my calendar
2) delete it if it was found
3) Creat a new one with the correct date (or the same if it was correct)
After a lot of forum visited, I created a prety simple code that do the job...But I have sometime the following error when the macro delete an appointment:
If no appointment is found, the code add correctly the 3 appointment ( 1) )
The following times I run the macro, it do that:
2) delete the 1st and error
3) creat the 1st and delete the 2nd and error
4) delete and creat the 1st, creat the 2nd and delete the last and error
5) delete the 1st and error
6) Creat the 1st and delete the 2nd and error
7) creat all and back to the step 1)
I already actived the Object Library
I'm in Excel 2013
Outlook 2013
Windows 7
About my sheet, I have 3 lines (1 for each appoitment) with subjet in Row A and date in Row 8, etc.
My appointment are in line 5, 6 and 7
I hope my post is complete and clear as possible
Thx for helping
Lexlut
I Just created a macro in order to :
1) check if an appoitment (by subject) is currently existing in my calendar
2) delete it if it was found
3) Creat a new one with the correct date (or the same if it was correct)
After a lot of forum visited, I created a prety simple code that do the job...But I have sometime the following error when the macro delete an appointment:
Execution error '-2147352567 (80020009)'
Automation ErrorException Occurred
If no appointment is found, the code add correctly the 3 appointment ( 1) )
The following times I run the macro, it do that:
2) delete the 1st and error
3) creat the 1st and delete the 2nd and error
4) delete and creat the 1st, creat the 2nd and delete the last and error
5) delete the 1st and error
6) Creat the 1st and delete the 2nd and error
7) creat all and back to the step 1)
Code:
Sub NouveauRDV_Calendrier()
Dim mbReply As VbMsgBoxResult
Dim OkApp As New Outlook.Application
Dim Rdv As Outlook.AppointmentItem
flag = 5
While Cells(flag, 8) <> "" 'flag = 5 To 10
'Test for duplicate event
Set myolApp = CreateObject("Outlook.Application")
Set myNameSpace = myolApp.GetNamespace("MAPI")
Set myolApp.ActiveExplorer.CurrentFolder = myNameSpace.GetDefaultFolder(olFolderCalendar)
Set outlookitems = myolApp.ActiveExplorer.CurrentFolder.Items
Cpte = outlookitems.Count
For x = 1 To Cpte
'same subject => delete
If outlookitems(x).Subject = Cells(flag, 1) Then
'outlookitems(x).Delete
outlookitems(x).Delete
End If
Next x
'in every case, I creat the new appointment
Set Rdv = OkApp.CreateItem(olAppointmentItem)
With Rdv
.MeetingStatus = olMeeting
.Subject = Cells(flag, 1)
.Body = Cells(flag, 2)
.Location = Cells(flag, 5)
.Start = Cells(flag, 8) & " 09:00:00"
.Duration = 60 'minutes
.Categories = "AUDIT"
.Save
End With
flag = flag + 1
Wend
Set OkApp = Nothing
End Sub
I already actived the Object Library
I'm in Excel 2013
Outlook 2013
Windows 7
About my sheet, I have 3 lines (1 for each appoitment) with subjet in Row A and date in Row 8, etc.
My appointment are in line 5, 6 and 7
I hope my post is complete and clear as possible
Thx for helping
Lexlut