Remove button from outlook toolbar

B

Bob Smith

Is there a way to forcefully hide or remove a button from an outlook add-in.
We still want the
add-in functional, just not the button on the tool bar in certain
situations. The vendor will not release the
source or make this feature enchancement for us.

I can do this with other buttons (below is the code to move the "Send and
Recieve" button). Whey I try it for this particular add-in button I get
"Run-time error '-2147467259 (8000405)': Method 'Visable' of the object
'_CommandBarButton' failed"

Dim standardBar As Office.CommandBar
Set moOL = Application
Dim count As Integer
Dim Index As Integer

count = moOL.ActiveExplorer.CommandBars.count
For Index = 1 To count
If "Standard" = moOL.ActiveExplorer.CommandBars.Item(Index).Name Then
Set standardBar = moOL.ActiveExplorer.CommandBars.Item(Index)
End If
Next Index


count = standardBar.Controls.count
For Index = 1 To count
If standardBar.Controls.Item(Index).Caption = "Send/Re&ceive" Then
standardBar.Controls.Item(Index).Visible = False
MsgBox "Hidden"
standardBar.Controls.Item(Index).Visible = True
MsgBox "Visible"
End If
Next Index
 
K

Ken Slovak - [MVP - Outlook]

Generally if this is a button in an existing toolbar such as Standard you
can't do anything about its visibility.

If the button is on a custom toolbar you can access it and turn off
visibility using code or in the UI from the View, Toolbars menu or the
Customize menu.
 
B

Baji

Hi Ken,

Can you please let me know, how can I create custom toolbar as you
mentioned above,

I am using vsto & also C#.net 2008 to create a new toolbar to outlook
2003.
when I am using the following code, am getting the toolbar , but the
toolbar..add remove buttons is grayed out.

commandBar = Application.ActiveExplorer().CommandBars.Add("Test", 1,
missing, true);

Any help in this is greately appreciated

Regards,
Baji.




Generally if this is a button in an existingtoolbarsuch as Standard you
can't do anything about its visibility.

If the button is on a customtoolbaryou can access it and turn off
visibility using code or in the UI from the View, Toolbars menu or the
Customize menu.

--
Ken Slovak
[MVP - Outlook]http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Optionshttp://www.slovaktech.com/products.htm


Is there a way to forcefully hide orremovea button from an outlook
add-in.
We still want the
add-in functional, just not the button on the tool bar in certain
situations. The vendor will not release the
source or make this feature enchancement for us.
I can do this with otherbuttons(below is the code to move the "Send and
Recieve" button). Whey I try it for this particularadd-in button I get
"Run-time error '-2147467259 (8000405)': Method 'Visable' of the object
'_CommandBarButton' failed"
Dim standardBar As Office.CommandBar
Set moOL = Application
Dim count As Integer
Dim Index As Integer
count = moOL.ActiveExplorer.CommandBars.count
For Index = 1 To count
If "Standard" = moOL.ActiveExplorer.CommandBars.Item(Index).Name Then
Set standardBar = moOL.ActiveExplorer.CommandBars.Item(Index)
End If
Next Index
count = standardBar.Controls.count
For Index = 1 To count
If standardBar.Controls.Item(Index).Caption = "Send/Re&ceive" Then
standardBar.Controls.Item(Index).Visible = False
MsgBox "Hidden"
standardBar.Controls.Item(Index).Visible = True
MsgBox "Visible"
End If
Next Index
 
K

Ken Slovak - [MVP - Outlook]

You can't add or remove buttons in the customize dialog with custom
toolbars. All you can do is to set the visibility of the toolbar in the
View, Toolbars menu. If you want to add or remove buttons in a custom
toolbar do it in code. If you want the user to be able to do that you must
create a custom dialog to do that.
 
B

Baji

Thanks for your reply Ken,

I got your point to write a custom dialog for the user to add remove
buttons,
But, how can I disable the add remove button option which is given by
Outlook by default.
Can you please throw me more light on this?

where can i find more examples, any articles or books you suggest.

Regards,
Baji.


You can't add or remove buttons in the customize dialog with custom
toolbars. All you can do is to set the visibility of the toolbar in the
View, Toolbars menu. If you want to add or remove buttons in a custom
toolbar do it in code. If you want the user to be able to do that you must
create a custom dialog to do that.

--
Ken Slovak
[MVP - Outlook]http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Optionshttp://www.slovaktech.com/products.htm


Can you please let me know, how can I create custom toolbar as you
mentioned above,
I am using vsto & also C#.net 2008 to create a new toolbar to outlook
2003.
when I am using the following code, am getting the toolbar , but the
toolbar..add remove buttons is grayed out.
commandBar = Application.ActiveExplorer().CommandBars.Add("Test", 1,
missing, true);
Any help in this is greately appreciated
Regards,
Baji.
 
K

Ken Slovak - [MVP - Outlook]

You can't disable the customization. There are a lot of things you can't do
with Outlook and you just have to live with them. Possibly the only way to
disable customization might be using a group policy when Outlook is
installed, but I'm not even sure about that.

There are lots of examples at www.outlookcode.com as well as a list of
Outlook books at different levels. One I recommend is my own book :)

I also have some code samples on my Web site, although not about this topic
and I have templates for Outlook addins for Outlook 2007 on my Web site for
managed and unmanaged code (VB6, VB.NET, C#, VB.NET/VSTO, C#/VSTO).
 
B

Baji

You can't disable the customization. There are a lot of things you can't do
with Outlook and you just have to live with them. Possibly the only way to
disable customization might be using a group policy when Outlook is
installed, but I'm not even sure about that.

There are lots of examples atwww.outlookcode.comas well as a list of
Outlook books at different levels. One I recommend is my own book :)

I also have some code samples on my Web site, although not about this topic
and I have templates for Outlook addins for Outlook 2007 on my Web site for
managed and unmanaged code (VB6, VB.NET, C#, VB.NET/VSTO, C#/VSTO).

--
Ken Slovak
[MVP - Outlook]http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Optionshttp://www.slovaktech.com/products.htm

Thanks, Ken.I Appreciate your valuable time.

& also, will get your book soon :)

Regards,
Baji.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top