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
Senniger1Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ProfessorJimJamMicrosoft Excel ExpertCommented:
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.
Senniger1Author Commented:
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
Senniger1Author Commented:
I think I need to use the GetSharedDefaultFolder but am not sure exactly how to use it.
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

ProfessorJimJamMicrosoft Excel ExpertCommented:
first of all, can you paste the original code that was working for you simply copying tasks to another local task Folder?

because the code you pasted, is messed up and with missing declarations prefixes of namespace and etc



in order to work with sharedfolders,  The Owner need to be Resolved. You can use the mailbox owner's display name, alias, or email address when resolving the recipient.

delete the line 50 from your code

then put the below code after 49th line

Dim objOwner As Outlook.Recipient
 Set objOwner = objNS.CreateRecipient("UpdateCPI")
 objOwner.Resolve
If objOwner.Resolved Then
Set objFolder = objNS.GetSharedDefaultFolder(objOwner, olFolderTasks)
End If

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Senniger1Author Commented:
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.
ProfessorJimJamMicrosoft Excel ExpertCommented:
Senniger1

did you modify the code as per my post ID: 40810336
it should work.
Senniger1Author Commented:
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.
ProfessorJimJamMicrosoft Excel ExpertCommented:
Great!  Thx for the feedback

Let me know how it goes
Senniger1Author Commented:
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!
ProfessorJimJamMicrosoft Excel ExpertCommented:
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
Senniger1Author Commented:
This was exactly what I needed to make my code work.  I really appreciate your help with this!
Senniger1Author Commented:
Oops, didn't mean to do that.  I think I have corrected it now.
ProfessorJimJamMicrosoft Excel ExpertCommented:
Thanks Senniger1
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Outlook

From novice to tech pro — start learning today.