Link to home
Start Free TrialLog in
Avatar of Senniger1
Senniger1

asked on

Outlook VBA to Move Task Item to Shared Task Folder

I have Outlook 2010.  I have a macro to take my task, make a copy of it and then move the COPY into another task folder.  From my mailbox this works perfectly because I'm an administrator so the other mailboxes are not shared mailboxes (see screenshot attachment for My Mailbox).

 I now need my users to have this code, but the mailbox "Update CPI" is a Shared Task folder in their mailbox which is what I want(see screenshot attachment for User Mailbox).

 Can this line of my code be altered to access a Shared Task Folder?
 "Set objFolder = GetFolder("UpdateCPI\Tasks")"

 Here is my entire code:
 Sub CopyTaskDDS()
 'Check how many items need to create tasks
 ' DDS for Docketing
     Select Case TypeName(Outlook.Application.ActiveWindow)
     Case "Inspector"
         CreateTaskfromObject Outlook.Application.ActiveInspector.CurrentItem
     Case "Explorer"
         Dim objItem As Object
         For Each objItem In Outlook.Application.ActiveExplorer.Selection
             CreateTaskfromObject objItem
         Next
     End Select
 End Sub
 Sub CreateTaskfromObject(objItem As Object)
 ' NOTE - This code uses CopyTaskDDS
 ' DDS for Docketing
 Dim objTask As Outlook.TaskItem
 Select Case objItem.Class
 Case olTask
   ' Duplicate the task (DDS)
     Dim objMainTask As TaskItem
     Set objTask = Application.CreateItem(olTaskItem)
     Set objMainTask = objItem
     Set objTask = objMainTask.Copy
     With objTask
 '        .Subject = "DDS of " & .Subject
         .Subject = .Subject
         .Save
 '       .Display
     End With
 End Select
 'Close original task
     With objMainTask
         objItem.Close olSave
     End With

 ' *** DDS MAILBOX ***
 ' *** Moves selected mail message to the DDS Task folder in the DDS mailbox ***
 ' NOTE - This code also uses GetFolder Function
     Dim obj As Object
     Dim i As Long
     Dim Sel As Selection
     Dim objFolder As Outlook.MAPIFolder
     Dim objTasks As Outlook.MAPIFolder
     Dim objNS As Outlook.NameSpace
     Dim moveTo As Outlook.Folder
     
     Set objNS = Application.GetNamespace("MAPI")
     Set objTasks = objNS.GetDefaultFolder(olFolderTasks)
     Set objFolder = GetFolder("UpdateCPI\Tasks")
     
     Set Sel = Application.ActiveExplorer.Selection
     For i = Sel.Count To 1 Step -1
         Set obj = Sel(i)
         Select Case True
         Case (TypeOf obj Is Outlook.TaskItem), (TypeOf obj Is Outlook.ReportItem)
            objTask.Move objFolder
         End Select
     Next
 End Sub

Open in new window

Can anyone assist me.

 Thank you in advance!
Screenshot.jpg
Avatar of Professor J
Professor J

it should work, but that depends on the level of permission set for the shared tasks folder.

if the shared tasks permission should have the ability to write and edit.
Avatar of Senniger1

ASKER

It doesn't work and the rights are fine.  I can manually do it.  I believe I just need the code to get it to the right path with is Shared Tasks/UpdateCPI
I think I need to use the GetSharedDefaultFolder but am not sure exactly how to use it.
ASKER CERTIFIED SOLUTION
Avatar of Professor J
Professor J

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The code I pasted above is the code I used.  It makes a copy of the task in my Task folder and moves the copy to the Task folder of an additional mailbox I have opened.

I just don't want to have to add this mailbox to every users mailbox in order for my code to work.  It would be better if it is just a Shared folder in which my users have delegated rights.
Senniger1

did you modify the code as per my post ID: 40810336
it should work.
Yes I just finished making the modifications.  I just wanted to respond promptly to let you know I provided my original working code.

It appears to be working now, but I want to test further.

I'll be in touch.
Great!  Thx for the feedback

Let me know how it goes
I've requested that this question be closed as follows:

Accepted answer: 0 points for Senniger1's comment #a40810409

for the following reason:

This was exactly what I needed to make my code work.  I really appreciate your help with this!
Senniger1

I think you have accepted your own comment as solution by mistake.

i hereby request Moderator to correct the aceepted answer to ID: 40810336
This was exactly what I needed to make my code work.  I really appreciate your help with this!
Oops, didn't mean to do that.  I think I have corrected it now.
Thanks Senniger1