![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
![]()
Trying to delete a shared task. Using this example:
Sub DeleteSharedTask() Dim objOL As Outlook.Application Dim objNS As Outlook.NameSpace Dim strFind As String Dim objCalFolder As Outlook.MAPIFolder Dim colCalendar As Outlook.Items Dim objAppt As Outlook.TaskItem Dim myRecipient As Outlook.recipient Set objOL = CreateObject("Outlook.Application") Set objNS = objOL.GetNamespace("MAPI") Set myRecipient = objNS.CreateRecipient("USER XYZ") myRecipient.Resolve If myRecipient.Resolved Then Set objTaskFolder = objNS.GetSharedDefaultFolder(myRecipient, olFolderTasks) Set colTask = objTaskFolder.Items strFind = "[Subject] = " & Chr(34) & "Test Delete" & Chr(34) Set objTask = colTask.Find(strFind) If Not objTask Is Nothing Then objTask.Delete End If End If Set objOL = Nothing Set objNS = Nothing Set objCalFolder = Nothing Set colCalendar = Nothing End Sub Error on the objTask.Delete = The operation failed. An object could not be found. I can debug and display the item, change the item, look at all of the itemproperties, but not delete. I have been granted ownership rights to the user's shared tasks. Any suggestions? |
#2
|
|||
|
|||
![]()
This really shouldn't make any difference, but see if it does. Grab the
EntryID and StoreID of the task item and release your objTask reference, then reinstantiate that or a new task object and see if you can then delete it. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "Job" wrote in message ... Trying to delete a shared task. Using this example: Sub DeleteSharedTask() Dim objOL As Outlook.Application Dim objNS As Outlook.NameSpace Dim strFind As String Dim objCalFolder As Outlook.MAPIFolder Dim colCalendar As Outlook.Items Dim objAppt As Outlook.TaskItem Dim myRecipient As Outlook.recipient Set objOL = CreateObject("Outlook.Application") Set objNS = objOL.GetNamespace("MAPI") Set myRecipient = objNS.CreateRecipient("USER XYZ") myRecipient.Resolve If myRecipient.Resolved Then Set objTaskFolder = objNS.GetSharedDefaultFolder(myRecipient, olFolderTasks) Set colTask = objTaskFolder.Items strFind = "[Subject] = " & Chr(34) & "Test Delete" & Chr(34) Set objTask = colTask.Find(strFind) If Not objTask Is Nothing Then objTask.Delete End If End If Set objOL = Nothing Set objNS = Nothing Set objCalFolder = Nothing Set colCalendar = Nothing End Sub Error on the objTask.Delete = The operation failed. An object could not be found. I can debug and display the item, change the item, look at all of the itemproperties, but not delete. I have been granted ownership rights to the user's shared tasks. Any suggestions? |
#3
|
|||
|
|||
![]()
Ken,
Your giving me too much credit. I'm not sure how to do what you've suggested. Would it be like this? a = objTask.Item("EntryID").Value b = objTask.Item("StoreID").Value Set objTask = Nothing Set objTask = ... not sure where to go..pretty new to this...thanks for your help "Ken Slovak - [MVP - Outlook]" wrote in message ... This really shouldn't make any difference, but see if it does. Grab the EntryID and StoreID of the task item and release your objTask reference, then reinstantiate that or a new task object and see if you can then delete it. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "Job" wrote in message ... Trying to delete a shared task. Using this example: Sub DeleteSharedTask() Dim objOL As Outlook.Application Dim objNS As Outlook.NameSpace Dim strFind As String Dim objCalFolder As Outlook.MAPIFolder Dim colCalendar As Outlook.Items Dim objAppt As Outlook.TaskItem Dim myRecipient As Outlook.recipient Set objOL = CreateObject("Outlook.Application") Set objNS = objOL.GetNamespace("MAPI") Set myRecipient = objNS.CreateRecipient("USER XYZ") myRecipient.Resolve If myRecipient.Resolved Then Set objTaskFolder = objNS.GetSharedDefaultFolder(myRecipient, olFolderTasks) Set colTask = objTaskFolder.Items strFind = "[Subject] = " & Chr(34) & "Test Delete" & Chr(34) Set objTask = colTask.Find(strFind) If Not objTask Is Nothing Then objTask.Delete End If End If Set objOL = Nothing Set objNS = Nothing Set objCalFolder = Nothing Set colCalendar = Nothing End Sub Error on the objTask.Delete = The operation failed. An object could not be found. I can debug and display the item, change the item, look at all of the itemproperties, but not delete. I have been granted ownership rights to the user's shared tasks. Any suggestions? |
#4
|
|||
|
|||
![]()
Try this:
a = objTask.EntryID b = objTask.Parent.StoreID Set objTask = Nothing Set objTask = oNS.GetItemFromID(a, b) If Not (objTask Is Nothing) Then objTask.Delete Set objTask = Nothing End If What version of Outlook? Where is this code running? It's obviously either VB6 or VBA code. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "Job" wrote in message ... Ken, Your giving me too much credit. I'm not sure how to do what you've suggested. Would it be like this? a = objTask.Item("EntryID").Value b = objTask.Item("StoreID").Value Set objTask = Nothing Set objTask = ... not sure where to go..pretty new to this...thanks for your help |
#5
|
|||
|
|||
![]()
Thanks for the code. It gives the same message. This has to do something
with the shared nature of the task. I can delete a shared task via code if i have the item selected in the window. For example I have a user PMO who shares it's tasks and I'm on owner. If I select that task folder then I can delete. It's when I'm referring to a shared task folder that is not in the current window. I'm using Outlook 2007. The code is running in that environment, VBA. "Ken Slovak - [MVP - Outlook]" wrote in message ... Try this: a = objTask.EntryID b = objTask.Parent.StoreID Set objTask = Nothing Set objTask = oNS.GetItemFromID(a, b) If Not (objTask Is Nothing) Then objTask.Delete Set objTask = Nothing End If What version of Outlook? Where is this code running? It's obviously either VB6 or VBA code. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "Job" wrote in message ... Ken, Your giving me too much credit. I'm not sure how to do what you've suggested. Would it be like this? a = objTask.Item("EntryID").Value b = objTask.Item("StoreID").Value Set objTask = Nothing Set objTask = ... not sure where to go..pretty new to this...thanks for your help |
#6
|
|||
|
|||
![]()
The purpose of the code is to do the following:
We want to use the tasks capability of Outlook and Exchange for project managment. The only way we've found to be able to assign tasks and have a central location is to assign a dummy user 'PMO' which shares it's tasks and give every user ownership rights. So each task that is assigned to users is essentially from PMO. The difficulty comes from the inability to recall the task. If I've assigned the task to UserA and I decided that I wanted to change the hours, not only on the main PMO, but also on the users machine, I've either got to have each of the user's shared folders avail to select and change (which would be too confusing for a lot of our users) or we came up with the idea to have a button or something that essentially (when in the PMO view) copies the selected task and fills in the custom fields to the new copied version of the task. As the task is copied it reassigns the task to PMO as the owner. Now we need to get rid of the task on the UserA's personal task list, thus the code you are helping with. The copied task would then be re-assigned to the user with the relevant changes. If we were able to effectivly recall the task it would make the process easier. However, I have all of the code to do everything described above minus the deleting of the original task off of the users personal task list to whom the task was orignially assigned. "Ken Slovak - [MVP - Outlook]" wrote in message ... Try this: a = objTask.EntryID b = objTask.Parent.StoreID Set objTask = Nothing Set objTask = oNS.GetItemFromID(a, b) If Not (objTask Is Nothing) Then objTask.Delete Set objTask = Nothing End If What version of Outlook? Where is this code running? It's obviously either VB6 or VBA code. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "Job" wrote in message ... Ken, Your giving me too much credit. I'm not sure how to do what you've suggested. Would it be like this? a = objTask.Item("EntryID").Value b = objTask.Item("StoreID").Value Set objTask = Nothing Set objTask = ... not sure where to go..pretty new to this...thanks for your help |
#7
|
|||
|
|||
![]()
Do you open the shared mailbox as part of the Outlook profile? I've found in
a lot of my code that things don't work as expected in delegate mailboxes unless the mailbox is opened as part of the profile and not by using File, Open in the UI or GetSharedDefaultFolder in code. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "Job" wrote in message ... The purpose of the code is to do the following: We want to use the tasks capability of Outlook and Exchange for project managment. The only way we've found to be able to assign tasks and have a central location is to assign a dummy user 'PMO' which shares it's tasks and give every user ownership rights. So each task that is assigned to users is essentially from PMO. The difficulty comes from the inability to recall the task. If I've assigned the task to UserA and I decided that I wanted to change the hours, not only on the main PMO, but also on the users machine, I've either got to have each of the user's shared folders avail to select and change (which would be too confusing for a lot of our users) or we came up with the idea to have a button or something that essentially (when in the PMO view) copies the selected task and fills in the custom fields to the new copied version of the task. As the task is copied it reassigns the task to PMO as the owner. Now we need to get rid of the task on the UserA's personal task list, thus the code you are helping with. The copied task would then be re-assigned to the user with the relevant changes. If we were able to effectivly recall the task it would make the process easier. However, I have all of the code to do everything described above minus the deleting of the original task off of the users personal task list to whom the task was orignially assigned. |
#8
|
|||
|
|||
![]()
Tried this and it gave me the same error:
If Not objTask Is Nothing Then a = objTask.ItemProperties.Item("EntryID").Value b = objTaskFolder.StoreID End If Set objTask = Nothing For Each t In colTask If t.ItemProperties.Item("EntryID").Value = a And objTaskFolder.StoreID = b Then t.Delete End If Next t "Ken Slovak - [MVP - Outlook]" wrote in message ... This really shouldn't make any difference, but see if it does. Grab the EntryID and StoreID of the task item and release your objTask reference, then reinstantiate that or a new task object and see if you can then delete it. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "Job" wrote in message ... Trying to delete a shared task. Using this example: Sub DeleteSharedTask() Dim objOL As Outlook.Application Dim objNS As Outlook.NameSpace Dim strFind As String Dim objCalFolder As Outlook.MAPIFolder Dim colCalendar As Outlook.Items Dim objAppt As Outlook.TaskItem Dim myRecipient As Outlook.recipient Set objOL = CreateObject("Outlook.Application") Set objNS = objOL.GetNamespace("MAPI") Set myRecipient = objNS.CreateRecipient("USER XYZ") myRecipient.Resolve If myRecipient.Resolved Then Set objTaskFolder = objNS.GetSharedDefaultFolder(myRecipient, olFolderTasks) Set colTask = objTaskFolder.Items strFind = "[Subject] = " & Chr(34) & "Test Delete" & Chr(34) Set objTask = colTask.Find(strFind) If Not objTask Is Nothing Then objTask.Delete End If End If Set objOL = Nothing Set objNS = Nothing Set objCalFolder = Nothing Set colCalendar = Nothing End Sub Error on the objTask.Delete = The operation failed. An object could not be found. I can debug and display the item, change the item, look at all of the itemproperties, but not delete. I have been granted ownership rights to the user's shared tasks. Any suggestions? |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Unable to delete a task request from inbox in outlook | [email protected] | Outlook - General Queries | 0 | March 8th 07 06:59 PM |
How to delete a recurrent task with a blocked remove recurrence | Dr Steve | Outlook - Calandaring | 0 | August 10th 06 05:36 PM |
How do I delete a Private appointment in a shared calendar? | WendyN201 | Outlook - Calandaring | 1 | June 13th 06 03:25 AM |
Handling Task Item Delete Event | AtulSureka | Outlook - Using Forms | 0 | January 24th 06 10:25 AM |
Delete / archive old entries in shared calendar in public folder | Slam | Outlook - Calandaring | 1 | January 18th 06 10:08 PM |