Remove Standard View in Outlook 2007?

  • Thread starter Thread starter Fidget Brain
  • Start date Start date
F

Fidget Brain

i have created a custom MAPIFolder and would like to remove some of the
default views. I get a COM exception when I try this. Is this a bug in the
Beta code or is it just not possible?

here is my code:

Outlook.Folder contactsFolder = (Outlook.Folder)
this.Application.GetNamespace("MAPI").GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts);
Outlook.Folder myFolder = (Outlook.Folder) contactsFolder.Add("MyFolder",
System.Reflection.Missing.Value);
myFolder.Views["By Location"].Delete();
 
It is not possible to remove any of the standard views in any version of Outlook. What about setting Folder.CustomViewsOnly = True instead?

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
I don't see a Delete method in the Object Browser for Outlook 2007 for Views
(or in earlier versions of Outlook either). At least here it's the Remove
method. If you're not sure about a method, property or event use the Object
Browser.
 
the preliminary Outlook 2007 developers documentation lists a Delete() and a
Remove() method. I have tried both of these methods in an attempt to remove
a standard view from the collection. I am able to remove a custom view that
I have added myself using these methods. However I am unable to remove a
standard view because I get a COM error.

The reason I am trying to do this is because I have set up a new
NavigationPane folder based on a custom MAPI Folder that I have created.
When a user clicks to insert a new item or edit an item from this MAPI
Folder, the form region I am exposing replaces the default Contacts form and
only user defined fields are visible. Urgo when a user clicks my navigation
folder, I do not want to display a list of Views to a user that are based on
the standard Outlook Contacts item. This does not make sense as my resulting
form will not expose these fields, so why would they want to see them listed
in its View?. Instead I want a customised Views list which shows only my
user defined fields.

it seems to me that if Microsoft are allowing developers to create form
regions which completely override and customise the original Contacts form,
then it follows that I would also need this for the Views on the navigation
pane as well?

this is a big sticking point for me as I cant seem to get info about how to
solve this. I will try your suggestion Sue. any more suggestions/help from
anybody would be greatly appreciated.

Ken Slovak - said:
I don't see a Delete method in the Object Browser for Outlook 2007 for
Views (or in earlier versions of Outlook either). At least here it's the
Remove method. If you're not sure about a method, property or event use the
Object Browser.




Fidget Brain said:
i have created a custom MAPIFolder and would like to remove some of the
default views. I get a COM exception when I try this. Is this a bug in the
Beta code or is it just not possible?

here is my code:

Outlook.Folder contactsFolder = (Outlook.Folder)
this.Application.GetNamespace("MAPI").GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts);
Outlook.Folder myFolder = (Outlook.Folder) contactsFolder.Add("MyFolder",
System.Reflection.Missing.Value);
myFolder.Views["By Location"].Delete();
 
sue

many thanks. the answer was right in front of me all this time. so sorry to
have wasted you time.

Fidget Brain said:
the preliminary Outlook 2007 developers documentation lists a Delete() and
a Remove() method. I have tried both of these methods in an attempt to
remove a standard view from the collection. I am able to remove a custom
view that I have added myself using these methods. However I am unable to
remove a standard view because I get a COM error.

The reason I am trying to do this is because I have set up a new
NavigationPane folder based on a custom MAPI Folder that I have created.
When a user clicks to insert a new item or edit an item from this MAPI
Folder, the form region I am exposing replaces the default Contacts form
and only user defined fields are visible. Urgo when a user clicks my
navigation folder, I do not want to display a list of Views to a user that
are based on the standard Outlook Contacts item. This does not make sense
as my resulting form will not expose these fields, so why would they want
to see them listed in its View?. Instead I want a customised Views list
which shows only my user defined fields.

it seems to me that if Microsoft are allowing developers to create form
regions which completely override and customise the original Contacts
form, then it follows that I would also need this for the Views on the
navigation pane as well?

this is a big sticking point for me as I cant seem to get info about how
to solve this. I will try your suggestion Sue. any more suggestions/help
from anybody would be greatly appreciated.

Ken Slovak - said:
I don't see a Delete method in the Object Browser for Outlook 2007 for
Views (or in earlier versions of Outlook either). At least here it's the
Remove method. If you're not sure about a method, property or event use
the Object Browser.




Fidget Brain said:
i have created a custom MAPIFolder and would like to remove some of the
default views. I get a COM exception when I try this. Is this a bug in
the Beta code or is it just not possible?

here is my code:

Outlook.Folder contactsFolder = (Outlook.Folder)
this.Application.GetNamespace("MAPI").GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts);
Outlook.Folder myFolder = (Outlook.Folder)
contactsFolder.Add("MyFolder", System.Reflection.Missing.Value);
myFolder.Views["By Location"].Delete();
 
Standard views can't be deleted using the Outlook object model, as Sue
pointed out and I missed. You can hack things using hidden messages but I'd
expect the standard views to be re-created if a switch like /cleanviews was
used to start Outlook.

I don't see any Delete method there in the Object Browser for the Views
collection. A View object has a Delete method but as far as I can see the
Views collection only has a Remove method.
 
Back
Top