[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2008-11-18
12
Medium Priority
?
308 Views
Last Modified: 2012-06-27
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?
0
Comment
Question by:carlosab
  • 6
  • 6
12 Comments
 
LVL 76

Expert Comment

by:David Lee
ID: 23056936
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
 

Author Comment

by:carlosab
ID: 23057866
What would be involved to do it using a custom task form or scripting?

Thanks.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 23057894
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:carlosab
ID: 23060376
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
 
LVL 76

Expert Comment

by:David Lee
ID: 23060728
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
 

Author Comment

by:carlosab
ID: 23060874
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
 
LVL 76

Expert Comment

by:David Lee
ID: 23064007
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
 
LVL 76

Accepted Solution

by:
David Lee earned 2000 total points
ID: 23064020
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
 

Author Comment

by:carlosab
ID: 23078583
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
 

Author Comment

by:carlosab
ID: 23079746
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
 

Author Closing Comment

by:carlosab
ID: 31517996
Thanks again.  I really appreciate it.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 23080017
You're welcome.  Glad I could help.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article lists the top 5 trialware OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their Exchange server is no longer available or other critical issues with Exchange server or impo…
Today as you open your Outlook, you witness an error message: “Outlook is using an old copy of your Outlook Data File…”. Probably, Outlook is accessing an old OST file.
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question