Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook and VBA (http://www.outlookbanter.com/outlook-vba/)
-   -   Delete Shared Task (http://www.outlookbanter.com/outlook-vba/58202-delete-shared-task.html)

Job[_2_] October 4th 07 01:24 AM

Delete Shared Task
 
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?


Ken Slovak - [MVP - Outlook] October 4th 07 02:39 PM

Delete Shared Task
 
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?



Job[_2_] October 4th 07 03:02 PM

Delete Shared Task
 
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?




Job[_2_] October 4th 07 03:29 PM

Delete Shared Task
 
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?




Ken Slovak - [MVP - Outlook] October 4th 07 03:43 PM

Delete Shared Task
 
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



Job[_2_] October 4th 07 04:23 PM

Delete Shared Task
 
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




Job[_2_] October 4th 07 04:39 PM

Delete Shared Task
 
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




Ken Slovak - [MVP - Outlook] October 4th 07 06:38 PM

Delete Shared Task
 
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.



Job[_2_] October 4th 07 08:32 PM

Delete Shared Task
 
Ken,

Are you talking about FileOpenOther User's FolderTasks? For this
particular user, yes I have that open, though in my code I get at that
folder by way of GetSharedDefaultFolder.



"Ken Slovak - [MVP - Outlook]" wrote in message
...
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.




Ken Slovak - [MVP - Outlook] October 4th 07 08:41 PM

Delete Shared Task
 
Yes, those are what I meant. That might be the root of the problem possibly.

--
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,

Are you talking about FileOpenOther User's FolderTasks? For this
particular user, yes I have that open, though in my code I get at that
folder by way of GetSharedDefaultFolder.




All times are GMT +1. The time now is 03:35 PM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com