J
jjjustinnn
Using the only working example I can find to search and delete OlItems based on a criteria, I have been able to successfully search out and delete OlCalendarItems, but not olTaskItems.
I can't understand why it works for one type of item in the model and not another. Any ideas
Here is an example of my code: The part after the doubleline doesn't 'search and destroy
Are there any code errors? I am a beginner
[/startcode
Dim olTsk As Outlook.TaskIte
Dim olAppt As Outlook.AppointmentIte
Dim ol As New Outlook.Applicatio
Dim delfol As Outlook.MAPIFolde
Dim ns As Outlook.NameSpac
Dim yyny As VbMsgBoxResul
Dim fdAppts As MAPIFolde
Dim fdTasks As MAPIFolde
Dim itmsAppointments As Outlook.Item
Dim ItmsTasks As Outlook.Item
Dim itm As Objec
Dim olApp As Outlook.Applicatio
Dim olNs As Objec
Dim Newdddate As Strin
Dim newstart As Objec
Dim OutlookApp As Objec
Const olAppointmentItem =
Const olTaskItem =
Set ns = OutlookApp.GetNamespace("MAPI"
'Reference the default Contacts folder and the
'return the Items collection of the folder
Set fdAppts = ns.GetDefaultFolder(olFolderCalendar
Set itmsAppointments = fdAppts.Item
'Establish the criteria and locate the Appt
criteria = "[Subject] = Due Today " & UserForm2.TextBox10.Value & " For " & UserForm2.TextBox5.Valu
Set itm = itmsAppointments.Find(criteria
'Determine if the item was found
If itm Is Nothing The
yyny = msgbox("Unable to locate the Outlook Calendar item. Continue and create new Item?", vbYesNo
If yyny = vbNo Then GoTo End
GoTo con
End I
'Delete the Appointment
Application.ScreenUpdating = Fals
Set delfol = ns.GetDefaultFolder(olFolderDeletedItems
On Error GoTo con
While TypeName(itm) <> "Nothing
itm.Move delfo
Wen
Application.ScreenUpdating = Tru
'====================================================
cont
Set fdTasks = ns.GetDefaultFolder(olFolderTasks
Set ItmsTasks = fdTasks.Items ' not workin
criteria = "[Subject] = "subject to be deleted"
itmm = ItmsTasks.Find(criteria) '??
''Determine if the Task was found
If itmm = "Nothing" The
yyny = msgbox("Unable to locate the Task. Continue and create new Task?", vbYesNo
If yyny = vbNo Then GoTo End
GoTo cont1
End I
'Delete the Tas
Set delfol = ns.GetDefaultFolder(olFolderDeletedItems
Application.ScreenUpdating = Fals
While TypeName(itmm) <> "Nothing
itmm.Move delfo
Wen
[/endcode
Thanks for any help, I'm very close to completing my first app
:-j. (e-mail address removed)
I can't understand why it works for one type of item in the model and not another. Any ideas
Here is an example of my code: The part after the doubleline doesn't 'search and destroy
Are there any code errors? I am a beginner
[/startcode
Dim olTsk As Outlook.TaskIte
Dim olAppt As Outlook.AppointmentIte
Dim ol As New Outlook.Applicatio
Dim delfol As Outlook.MAPIFolde
Dim ns As Outlook.NameSpac
Dim yyny As VbMsgBoxResul
Dim fdAppts As MAPIFolde
Dim fdTasks As MAPIFolde
Dim itmsAppointments As Outlook.Item
Dim ItmsTasks As Outlook.Item
Dim itm As Objec
Dim olApp As Outlook.Applicatio
Dim olNs As Objec
Dim Newdddate As Strin
Dim newstart As Objec
Dim OutlookApp As Objec
Const olAppointmentItem =
Const olTaskItem =
Set ns = OutlookApp.GetNamespace("MAPI"
'Reference the default Contacts folder and the
'return the Items collection of the folder
Set fdAppts = ns.GetDefaultFolder(olFolderCalendar
Set itmsAppointments = fdAppts.Item
'Establish the criteria and locate the Appt
criteria = "[Subject] = Due Today " & UserForm2.TextBox10.Value & " For " & UserForm2.TextBox5.Valu
Set itm = itmsAppointments.Find(criteria
'Determine if the item was found
If itm Is Nothing The
yyny = msgbox("Unable to locate the Outlook Calendar item. Continue and create new Item?", vbYesNo
If yyny = vbNo Then GoTo End
GoTo con
End I
'Delete the Appointment
Application.ScreenUpdating = Fals
Set delfol = ns.GetDefaultFolder(olFolderDeletedItems
On Error GoTo con
While TypeName(itm) <> "Nothing
itm.Move delfo
Wen
Application.ScreenUpdating = Tru
'====================================================
cont
Set fdTasks = ns.GetDefaultFolder(olFolderTasks
Set ItmsTasks = fdTasks.Items ' not workin
criteria = "[Subject] = "subject to be deleted"
itmm = ItmsTasks.Find(criteria) '??
''Determine if the Task was found
If itmm = "Nothing" The
yyny = msgbox("Unable to locate the Task. Continue and create new Task?", vbYesNo
If yyny = vbNo Then GoTo End
GoTo cont1
End I
'Delete the Tas
Set delfol = ns.GetDefaultFolder(olFolderDeletedItems
Application.ScreenUpdating = Fals
While TypeName(itmm) <> "Nothing
itmm.Move delfo
Wen
[/endcode
Thanks for any help, I'm very close to completing my first app
:-j. (e-mail address removed)