lock task views?

Status
Not open for further replies.

astro46

Senior Member
Outlook version
Outlook 2016 64 bit
Email Account
IMAP
too often do I accidentally click the "subject" heading, causing tasks to rearrange in alphabetical order. Then, to retrieve my preferred settings for this custom view I have to click through all the view modification settings to set order back to "none". frustrating and a waste time.

Is there no way to either lock the view so that it can't be accidentally modified (preferred), or easily put it back to the view that is intended?
 
This is the code I'm testing and it doesn't seem to be working in 2013 - at least not for the mailbox owner.

Code:
Sub LocksPublicViews()
'Locks the interface of all views that are available to
'all users of this folder.
Dim objName As Outlook.NameSpace
Dim objViews As Outlook.Views
Dim objView As Outlook.View
Set objName = Application.GetNamespace("MAPI")
Set objViews = objName.GetDefaultFolder(olFolderInbox).Views
'Set objViews = Application.CurrentFolder.Views
For Each objView In objViews
'If objView.SaveOption = olViewSaveOptionAllFoldersOfType Then
Call LockView(objView, True)
'End If
Next objView 
 
End Sub 
 
Sub LockView(ByRef objView As View, ByVal blnAns As Boolean)
'Locks the user interface of the view.
'Accepts and returns a View object and user response.
With objView
If blnAns = True Then
'if true lock UI
.LockUserChanges = True
.Save
Else
'if false don't lock UI
.LockUserChanges = False
End If
End With 
 
End Sub
 
Need more coffee this morning... :) The macro doesn't prevent you from resorting fields, but the changes aren't saved back to the view - so when you leave the folder and return, the original view is restored.
 
Diane, thanks for taking the time to write the code. I made a copy of the view that I am most concerned with, setting 'can be used on ' as "this folder, private". so that the macro would only affect that view.

then i changed "olViewSaveOptionThisFolderEveryone" to "olViewSaveOptionThisFolderOnlyMe", and, lowered security setting, and ran the macro from the vba editor. I didn't find that it helped. I tried changing views, closing and reopening the task folder. still, the view was stuck in sorting according to subject (having clicked on the subject heading. )

this isn't to say that the macro isn't correct. could easily be user error, not using the macro correctly, etc.
 
I'll check it with the condition - i tried a few conditions then remove the IF line and applied it to all views - I could change the views but the changes didn't stick when i left and returned.

Is the view on the inbox? This line controls the folder:
Set objViews = objName.GetDefaultFolder(olFolderInbox).Views
 
its a task view. i have a number of different task lists under "my tasks". (perhaps i am organizing tasks incorrectly?). at the moment i am focusing on a particular task list. it isn't clear to me if 'my tasks' is the folder, or each of the lists is also a folder.

iac, i will try changing: Set objViews = objName.GetDefaultFolder(olFolderInbox).Views to: Set objViews = objName.GetDefaultFolder(olFolderTasks).Views and see what happens. tomorrow.
 
That should work. Sorry I forgot to mention that before.
 
I changed "inbox" to "tasks, as indicated above, changed "olViewSaveOptionThisFolderEveryone" to "olViewSaveOptionThisFolderOnlyMe", lowered macro security settings and ran macro. then iI hit a column heading to re-order the tasks. this meant that I could no longer move tasks around into custom order, as i could before running the macro. I then changed views, closed tasks and reopened, closed outlook and reopened. Still can't custom order the tasks. my original view hasn't returned.

apparently this is much more complicated to get then I hoped for in original question. oh well.
 
I will test this scenario - I used it on Email. I know the dragging tasks to reorder thingy is limited to certain views - that was the result of your changing views not, the macro.

The view you switched to, was it an everyone view? The macro doesn't lock the folder to a specific view, it prevents changes from being saved to a view. If you use the original view, change the sort order then leave and return, the original sort order should come back.

It is possible to always use a specific view when you open a folder - I have sample code at the bottom of this page: Open the Calendar pane to a specific Calendar and view
 
perhaps to save your time, and eliminate errors on my part, here is the vba code that I ran:

--------------------------
Sub LocksPublicViews()
'Locks the interface of all views that are available to
'all users of this folder.
Dim objName As Outlook.NameSpace
Dim objViews As Outlook.Views
Dim objView As Outlook.View
Set objName = Application.GetNamespace("MAPI")
Set objViews = objName.GetDefaultFolder(olFolderTasks).Views
For Each objView In objViews
If objView.SaveOption = olViewSaveOptionThisFolderOnlyMe Then
Call LockView(objView, True) ' False = unlock
End If
Next objView

End Sub

Sub LockView(ByRef objView As View, ByVal blnAns As Boolean)
With objView
If blnAns = True Then
'if true lock UI
.LockUserChanges = True
.Save
Else
'if false don't lock UI
.LockUserChanges = False
End If
End With

End Sub

----i made a duplicate of the particular tasks list that i am trying this on, shown below, "custom order, no modifications"

tasklist.JPG

I run the script, then click on column heading, which changes order, and removes (this is the frustrating part) the ability to drag items to a different order. I then go to a different task list, or close tasks and reopen, even try closing outlook and reopening; nothing brings back the original custom task settings allowing me to drag tasks to a custom order. (until i go into settings and change the column sort setting back to "none"). perhaps I don't understand what you mean by closing folder, or whatever it is that you do to reestablish original settings.
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
R Outlook 2007 or 2010 - Lock Down Functionality Outlook VBA and Custom Forms 3
D File Lock issue when saving message from Outlook to new folder Using Outlook 1
wallisellener email lock BCM (Business Contact Manager) 1
D "lock" a message so it can not be deleted Using Outlook 2
A Lock the distribution list Using Outlook 1
H want to Lock appointment which are cerated from my code Outlook VBA and Custom Forms 2
S Create Outlook Task from Template and append Body with Email Body Outlook VBA and Custom Forms 4
D Copy Appointment Body to Task Body Outlook VBA and Custom Forms 0
K Daily Task List Minimized Cannot Display Using Outlook 5
wayneame Changing the Form Used by Existing Task Items in a Folder Outlook VBA and Custom Forms 4
S Outlook 2016 Understand and customize prepended behavior of recurring task Using Outlook 0
B Outlook 365 Populate Outlook Task UDFs from a UDF text string Outlook VBA and Custom Forms 2
K Multiple copies of task being created Using Outlook 2
P Short Date Format when typing in a task Using Outlook 2
C Outlook 2013 Task Recurrence - Third Friday After the Second Tuesday Using Outlook 2
P Task display now leaves little room for notes Using Outlook 10
C-S-R How to clear an Outlook (To Do) Task Flag? Using Outlook 8
G Event when creating task from mailitem Outlook VBA and Custom Forms 2
P Changing the font that the task view shows Using Outlook 5
D How To Combine Share Task Folders in just one Folder Using Outlook 0
P Can I create a Rule that sends me an email when I get a Task? Using Outlook 2
G Arggh, weakness of reminder for every Task recurrence Using Outlook 0
P Can't paste an image into a task Using Outlook 3
F Validation on custom task form after task acceptance Outlook VBA and Custom Forms 1
J Office 365 erased all of my task views Using Outlook 3
T Report For Task Recurrance Outlook VBA and Custom Forms 4
E Can't accept or decline task (no button appears) Using Outlook 2
Z VBA to convert email to task, insert text of email in task notes, and attach copy of original email Outlook VBA and Custom Forms 4
Z Task Filter Not Working When I add too many criteria Using Outlook 0
X If you change expiration date of repeated task it dupplicates Using Outlook 1
Z How to show concatenated categories in list task view? Using Outlook 2
Z VBA to Collapse Task Folder Groups Outlook VBA and Custom Forms 1
E To convert imported data to custom fields in Task list Outlook VBA and Custom Forms 1
I Help with dates in task list. Using Outlook 5
Y Outlook Task View - Table Format - Customize Reminder Time to Drop-Down Selection Using Outlook 2
M Daily Task List Minimized Cannot Display Using Outlook 2
D Using a VBA Custom Form to Send Reoccurring Email Upon Task Completion Outlook VBA and Custom Forms 4
P Add a contact to the New Task in Outlook 2016 Using Outlook 2
S Codes for "Mark Complete" the task Outlook VBA and Custom Forms 2
W Deleting Sent Task Email, Deletes the task from my list Using Outlook 1
K Task priority modification Using Outlook 4
F Search folder for tasks in all task folders Using Outlook 1
JohnViuf Export task list view settings to other pc Outlook VBA and Custom Forms 16
V Changing default date for task follow-up buttons Using Outlook 2
K outlook workflow: automated task generation Outlook VBA and Custom Forms 4
U HTML Task Alternate Home Page View Control Using Outlook 3
F How to assign a task to a public task folder? Using Outlook 1
J Marketing task MS BCM BCM (Business Contact Manager) 10
copperberry How to view all tasks across task folders Using Outlook 3
P Task Categories Using Outlook 2

Similar threads

Back
Top