Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Outlook Automation, Deleting Tasks

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Outlook Automation, Deleting Tasks

Why not post this in an Outlook newsgroup rather than an Excel news group.
There doesn't seem to be anything here that has to do with Excel.

--
Regards,
Tom Ogilvy

jjjustinnn wrote in message
...
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.TaskItem
Dim olAppt As Outlook.AppointmentItem
Dim ol As New Outlook.Application
Dim delfol As Outlook.MAPIFolder
Dim ns As Outlook.NameSpace
Dim yyny As VbMsgBoxResult
Dim fdAppts As MAPIFolder
Dim fdTasks As MAPIFolder
Dim itmsAppointments As Outlook.Items
Dim ItmsTasks As Outlook.Items
Dim itm As Object
Dim olApp As Outlook.Application
Dim olNs As Object
Dim Newdddate As String
Dim newstart As Object
Dim OutlookApp As Object
Const olAppointmentItem = 1
Const olTaskItem = 3

Set ns = OutlookApp.GetNamespace("MAPI")
'Reference the default Contacts folder and then
'return the Items collection of the folder.
Set fdAppts = ns.GetDefaultFolder(olFolderCalendar)
Set itmsAppointments = fdAppts.Items
'Establish the criteria and locate the Appt.
criteria = "[Subject] = Due Today " & UserForm2.TextBox10.Value & "

For " & UserForm2.TextBox5.Value
Set itm = itmsAppointments.Find(criteria)
'Determine if the item was found.
If itm Is Nothing Then
yyny = msgbox("Unable to locate the Outlook Calendar item.

Continue and create new Item?", vbYesNo)
If yyny = vbNo Then GoTo End1
GoTo cont
End If
'Delete the Appointment.
Application.ScreenUpdating = False
Set delfol = ns.GetDefaultFolder(olFolderDeletedItems)
On Error GoTo cont
While TypeName(itm) < "Nothing"
itm.Move delfol
Wend
Application.ScreenUpdating = True
'================================================= ====
cont:
Set fdTasks = ns.GetDefaultFolder(olFolderTasks)
Set ItmsTasks = fdTasks.Items ' not working
criteria = "[Subject] = "subject to be deleted"
itmm = ItmsTasks.Find(criteria) '???
''Determine if the Task was found.
If itmm = "Nothing" Then
yyny = msgbox("Unable to locate the Task. Continue and create new

Task?", vbYesNo)
If yyny = vbNo Then GoTo End1
GoTo cont11
End If
'Delete the Task
Set delfol = ns.GetDefaultFolder(olFolderDeletedItems)
Application.ScreenUpdating = False
While TypeName(itmm) < "Nothing"
itmm.Move delfol
Wend
[/endcode]
Thanks for any help, I'm very close to completing my first app.
:-j.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Outlook Automation, Deleting Tasks



Actually, my application is referencing Outlook from Excel vb.
In the mean time, I have found a solution that works.
The working solution is at
http://msdn.microsoft.com/library/de.../en-us/dnout2k
2/html/odc_novoltips.asp

Thanks.
-justin

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Outlook Automation, Deleting Tasks

Which has a title of:

Ten Tips for Microsoft Outlook Developers (November 2002)
and says:

Applies to:
Microsoft® Outlook® 2002

so where you manipulate outlook from is pretty much moot.

Glad you found a solution though.

--
Regards,
Tom Ogilvy

jjjustinnn wrote in message
...


Actually, my application is referencing Outlook from Excel vb.
In the mean time, I have found a solution that works.
The working solution is at
http://msdn.microsoft.com/library/de.../en-us/dnout2k
2/html/odc_novoltips.asp

Thanks.
-justin

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Counting tasks slavenp Excel Discussion (Misc queries) 0 August 6th 09 04:16 PM
Using Outlook Tasks from Excel... Devon Excel Discussion (Misc queries) 0 March 5th 09 04:51 PM
Exporting tasks se7098 Excel Worksheet Functions 2 January 21st 09 03:37 PM
deleting outlook Suzi0110 Excel Discussion (Misc queries) 5 August 11th 08 01:41 AM
Having links from excel spreadsheet to my outlook tasks soleil Excel Discussion (Misc queries) 1 May 13th 06 12:12 PM


All times are GMT +1. The time now is 11:27 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"