Disable ability to delete a task other than from within the task itself.

When viewing the entire list of tasks, it is too easy to accidentally delete a task merely by pressing the delete button.  Can I configure Outlook so that a user cannot delete a task unless he actually enters the task and then clicks on the "delete" icon?  If the answer is no, then can Outlook be configured so that if the delete button is pressed when a task is selected on the entire task list, then a confirmation prompt will appear to verify the deletion before actually deleting he task?
carlosabAsked:
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.

David LeeCommented:
Hi, carlosab.

The answer to both questions is "no".  Outlook does not have configuration options for doing either.  If you want to change to using a custom task form, then this is possible.  It might also be possible with a bit of scripting.
0
carlosabAuthor Commented:
What would be involved to do it using a custom task form or scripting?

Thanks.
0
David LeeCommented:
The former is simpler than the latter.  Using a custom form you'd add code behind the form that would detect when a user attempts to delete an item and display the confirmation prompt.  The scripting approach does the same thing, so the code is similar.  It's just more difficult to keep track of which items are open and therefore which one a user is trying to delete.  The form approach is relatively easy to build (probably about 10 lines of code), but complicated in that it requires changing everyone to use the new form.  The script approach requires more code (50 - 100 lines) and that script has to be added to everyone's computer.  
0
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.

carlosabAuthor Commented:
I don't have that many users, so, changing everyone to use the new form wouldn't be that difficult.  Would you be able to provide code and instructions for adding to the form?

Thanks,
0
David LeeCommented:
The code for this is very simple.  Here's what you'll need to do.

1.  Create a custom task form.
2.  Add this code to the form.  (Click the View Code button on the Developer tab.  Cut and paste the code into the resulting window.)
3.  Save and publish the form.
4.  Update all existing tasks to use the new form.
5.  Set the custom form as the default task form.

Here's a link to more information on creating and using custom forms in Outlook:  http://www.outlookcode.com/  
Look at the list of form topics on the left sidebar under "Outlook Forms"
Sub Item_BeforeDelete(Item, Cancel)
    If Msgbox("Are you sure you want to delete this task?",vbQuestion+vbYesNo,"Confirm Task Deletion") = vbNo Then
        Cancel = True
    End If
End Sub

Open in new window

0
carlosabAuthor Commented:
Thanks so far.  We are making progress.

I did steps 1-3 and #5.  Now, when I make a new task, it uses the new form.  But, there is still no prompt if the delete button is pressed before entering a task that has been selected on the entire task list.  Instead, I get the prompt only if I have already entered the task and clicked on the delete icon.  Also, even if I click "no" after getting the prompt, it still deletes the task.

Thanks again.


0
David LeeCommented:
Apologies.  I got my VBA and VBScript versions confused.  Use this version instead.

This approach only blocks deletion when the user has the item open and attempts to delete it.  
Function Item_BeforeDelete(Item, Cancel)
    If Msgbox("Are you sure you want to delete this task?",vbQuestion+vbYesNo,"Confirm Task Deletion") = vbNo Then
        Item_BeforeDelete = False
    End If
End Function

Open in new window

0
David LeeCommented:
This code does the same thing when a user tries to delete the item without opening it.  This code does not go in the form.  Instead, follow these instructions to use it.

1.  Start Outlook
2.  Click Tools->Macro->Visual Basic Editor
3.  If not already expanded, expand Microsoft Office Outlook Objects and click on ThisOutlookSession
4.  Copy the code from the Code Snippet box and paste it into the right-hand pane of Outlook's VB Editor window
5.  Edit the code as needed.  I included comment lines wherever something needs to or can change
6.  Click the diskette icon on the toolbar to save the changes
7.  Close the VB Editor
8.  Click Tools > Trust Center
9.  Click Macro Security
10. Set Macro Security to "Warnings for all macros"
11. Click OK
12. Close Outlook
13. Start Outlook.  Outlook will display a dialog-box warning that ThisOutlookSession contains macros and asking if you want to allow them to run.  Say yes.

This will have to be done on each computer.
Private WithEvents olkTasks As Outlook.Folder
 
Private Sub Application_Quit()
    Set objTasks = Nothing
End Sub
 
Private Sub Application_Startup()
    'Change the folder path on the next line to point to your tasks folder'
    Set olkTasks = OpenOutlookFolder("Testing\Test Tasks")
End Sub
 
Private Sub olkTasks_BeforeItemMove(ByVal Item As Object, ByVal MoveTo As MAPIFolder, Cancel As Boolean)
    If InStr(1, MoveTo.FolderPath, "Deleted Items") Then
        If MsgBox("Are you sure you want to delete this task?", vbQuestion + vbYesNo, "Confirm Task Deletion") = vbNo Then
            Cancel = True
        End If
    End If
End Sub
 
Function IsNothing(obj)
  If TypeName(obj) = "Nothing" Then
    IsNothing = True
  Else
    IsNothing = False
  End If
End Function
 
Function OpenOutlookFolder(strFolderPath As String) As Outlook.MAPIFolder
    Dim arrFolders As Variant, _
        varFolder As Variant, _
        olkFolder As Outlook.MAPIFolder
    On Error GoTo ehOpenOutlookFolder
    If strFolderPath = "" Then
        Set OpenOutlookFolder = Nothing
    Else
        Do While Left(strFolderPath, 1) = "\"
            strFolderPath = Right(strFolderPath, Len(strFolderPath) - 1)
        Loop
        arrFolders = Split(strFolderPath, "\")
        For Each varFolder In arrFolders
            If IsNothing(olkFolder) Then
                Set olkFolder = Session.Folders(varFolder)
            Else
                Set olkFolder = olkFolder.Folders(varFolder)
            End If
        Next
        Set OpenOutlookFolder = olkFolder
    End If
    On Error GoTo 0
    Exit Function
ehOpenOutlookFolder:
    Set OpenOutlookFolder = Nothing
    On Error GoTo 0
End Function

Open in new window

0

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
carlosabAuthor Commented:
I wasn't able to follow the instructions precisely.  Here is where I got hung up:

"3.  If not already expanded, expand Microsoft Office Outlook Objects and click on ThisOutlookSession
4.  Copy the code from the Code Snippet box and paste it into the right-hand pane of Outlook's VB Editor window"

I couldn't find "Microsoft Office Outlook Objects".  Instead, I pressed F2 to open Object Browser.  Then I double-clicked on ThisOutlookSession in the left pane.  That opened a window named Microsoft Visual Basic - VbaProject.OTM - [thisOutlookSession (Code)].  I pasted the code from the Code Snippet box in that window.


"5.  Edit the code as needed.  I included comment lines wherever something needs to or can change"

For this, the only comment line that I saw was 'Change the folder path on the next line to point to your tasks folder'.  I wasn't sure how to identify the correct folder path for the tasks folder.  I right clicked on the icon that I click to open my tasks folder (that icon is "Tasks" located under "My Tasks") and then selected Properties.   On the General tab, it says "Location \\Mailbox - Carlo Sabatini".  So, I replaced the ("Testing\Test Tasks") in your code with ("\\Mailbox - Carlo Sabatini\Tasks").  I also tried replacing it with ("Mailbox - Carlo Sabatini\Tasks").


I don't get the dialog warning box indicated in your Step 13.
Thanks again.
0
carlosabAuthor Commented:
I just restarted the computer and now it is working.  I guess when I exited outlook and reopened before, it didn't close all the way.  Thanks a lot!
0
carlosabAuthor Commented:
Thanks again.  I really appreciate it.
0
David LeeCommented:
You're welcome.  Glad I could help.
0
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.