A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Create a custom toolbar



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old February 28th 06, 10:02 PM posted to microsoft.public.outlook.program_vba
Rhonda
external usenet poster
 
Posts: 19
Default Create a custom toolbar

I have a macro to insert text in the subject line and message box of a new
mail message. I can create a custom toolbar button on the new mail message
Standard toolbar. I know that I can save the VBProject.OTM on the person's
hard drive but they must assign the toolbar button. The question I have is
if there is a way to distribute this solution to other users without them
having to assign the macro to a toolbar?
Ads
  #2  
Old March 1st 06, 06:46 AM posted to microsoft.public.outlook.program_vba
Michael Bauer
external usenet poster
 
Posts: 435
Default Create a custom toolbar

Am Tue, 28 Feb 2006 14:02:31 -0800 schrieb Rhonda:

You can create a CommandBar by code. Here´s a sample. You can call the
CreateCommandBarButton function from within the NewInspector event. For the
ability to use more than one Inspector at once you´d need an Inspector
wrapper; a sample is at:
http://www.slovaktech.com/code_sampl...spectorWrapper

Private WithEvents Button As Office.CommandBarButton

Private Sub Button_Click(ByVal Ctrl As Office.CommandBarButton,
CancelDefault As Boolean)
'
End Sub

Private Function CreateCommandBarButton(oBars As Office.CommandBars) As
Office.CommandBarButton
On Error Resume Next
Dim oMenu As Office.CommandBar
Dim oBtn As Office.CommandBarButton
Const BAR_NAME As String = "YourCommandBarName"
Const CMD_NAME As String = "YourButtonName"

Set oMenu = oBars(BAR_NAME)
If oMenu Is Nothing Then
Set oMenu = oBars.Add(BAR_NAME, msoBarTop, , True)
Set oBtn = oMenu.Controls.Add(msoControlButton, , CMD_NAME, , True)
oBtn.Caption = CMD_NAME
oBtn.Tag = CMD_NAME

Else
Set oBtn = oMenu.FindControl(, , CMD_NAME)
If oBtn Is Nothing Then
Set oBtn = oMenu.Controls.Add(msoControlButton, , CMD_NAME, , True)
End If
End If

oMenu.Visible = True
Set CreateCommandBarButton = oBtn
End Function
--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


I have a macro to insert text in the subject line and message box of a new
mail message. I can create a custom toolbar button on the new mail

message
Standard toolbar. I know that I can save the VBProject.OTM on the

person's
hard drive but they must assign the toolbar button. The question I have

is
if there is a way to distribute this solution to other users without them
having to assign the macro to a toolbar?

  #3  
Old March 1st 06, 03:15 PM posted to microsoft.public.outlook.program_vba
Rhonda
external usenet poster
 
Posts: 19
Default Create a custom toolbar

Thanks Michael,

I am new to the WithEvents function. Where should I place this code, at the
module level or in a separate module?

"Michael Bauer" wrote:

Am Tue, 28 Feb 2006 14:02:31 -0800 schrieb Rhonda:

You can create a CommandBar by code. Here´s a sample. You can call the
CreateCommandBarButton function from within the NewInspector event. For the
ability to use more than one Inspector at once you´d need an Inspector
wrapper; a sample is at:
http://www.slovaktech.com/code_sampl...spectorWrapper

Private WithEvents Button As Office.CommandBarButton

Private Sub Button_Click(ByVal Ctrl As Office.CommandBarButton,
CancelDefault As Boolean)
'
End Sub

Private Function CreateCommandBarButton(oBars As Office.CommandBars) As
Office.CommandBarButton
On Error Resume Next
Dim oMenu As Office.CommandBar
Dim oBtn As Office.CommandBarButton
Const BAR_NAME As String = "YourCommandBarName"
Const CMD_NAME As String = "YourButtonName"

Set oMenu = oBars(BAR_NAME)
If oMenu Is Nothing Then
Set oMenu = oBars.Add(BAR_NAME, msoBarTop, , True)
Set oBtn = oMenu.Controls.Add(msoControlButton, , CMD_NAME, , True)
oBtn.Caption = CMD_NAME
oBtn.Tag = CMD_NAME

Else
Set oBtn = oMenu.FindControl(, , CMD_NAME)
If oBtn Is Nothing Then
Set oBtn = oMenu.Controls.Add(msoControlButton, , CMD_NAME, , True)
End If
End If

oMenu.Visible = True
Set CreateCommandBarButton = oBtn
End Function
--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


I have a macro to insert text in the subject line and message box of a new
mail message. I can create a custom toolbar button on the new mail

message
Standard toolbar. I know that I can save the VBProject.OTM on the

person's
hard drive but they must assign the toolbar button. The question I have

is
if there is a way to distribute this solution to other users without them
having to assign the macro to a toolbar?


  #4  
Old March 1st 06, 05:33 PM posted to microsoft.public.outlook.program_vba
Dave Kane [MVP - Outlook]
external usenet poster
 
Posts: 33
Default Create a custom toolbar

This would all go in ThisOutlookSession. The Button object is a module-level
variable. The WithEvents keyword tells VBA to create handlers for any events
that the object exposes - you will see "Button" (or whatever variable name
you choose) in the left-hand dropdown above the code window, where
"(General)" and "Application" currently appear. The Click event will appear
in the right-hand dropdown when "Button" is selected in the left.

"Rhonda" wrote in message
...
Thanks Michael,

I am new to the WithEvents function. Where should I place this code, at
the
module level or in a separate module?

"Michael Bauer" wrote:

Am Tue, 28 Feb 2006 14:02:31 -0800 schrieb Rhonda:

You can create a CommandBar by code. Here´s a sample. You can call the
CreateCommandBarButton function from within the NewInspector event. For
the
ability to use more than one Inspector at once you´d need an Inspector
wrapper; a sample is at:
http://www.slovaktech.com/code_sampl...spectorWrapper

Private WithEvents Button As Office.CommandBarButton

Private Sub Button_Click(ByVal Ctrl As Office.CommandBarButton,
CancelDefault As Boolean)
'
End Sub

Private Function CreateCommandBarButton(oBars As Office.CommandBars) As
Office.CommandBarButton
On Error Resume Next
Dim oMenu As Office.CommandBar
Dim oBtn As Office.CommandBarButton
Const BAR_NAME As String = "YourCommandBarName"
Const CMD_NAME As String = "YourButtonName"

Set oMenu = oBars(BAR_NAME)
If oMenu Is Nothing Then
Set oMenu = oBars.Add(BAR_NAME, msoBarTop, , True)
Set oBtn = oMenu.Controls.Add(msoControlButton, , CMD_NAME, , True)
oBtn.Caption = CMD_NAME
oBtn.Tag = CMD_NAME

Else
Set oBtn = oMenu.FindControl(, , CMD_NAME)
If oBtn Is Nothing Then
Set oBtn = oMenu.Controls.Add(msoControlButton, , CMD_NAME, , True)
End If
End If

oMenu.Visible = True
Set CreateCommandBarButton = oBtn
End Function
--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


I have a macro to insert text in the subject line and message box of a
new
mail message. I can create a custom toolbar button on the new mail

message
Standard toolbar. I know that I can save the VBProject.OTM on the

person's
hard drive but they must assign the toolbar button. The question I
have

is
if there is a way to distribute this solution to other users without
them
having to assign the macro to a toolbar?




  #5  
Old April 5th 06, 04:11 AM posted to microsoft.public.outlook.program_vba
carl
external usenet poster
 
Posts: 40
Default Create a custom toolbar

Hi,

I'm trying to do something similar. I have a sub which launches the
application we need to launch.

I can manually attach this to a button in a toolbar, but we want to roll
this out to all users in the organisation. Is there some VBScript style code
we can run on login which will add the button and the appropriate _click code
to their workstation?

Thanks,
Carl
  #6  
Old April 5th 06, 12:39 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Create a custom toolbar

The right solution would be to develop this as an Outlook add-in and install the add-in on each machine.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"Carl" wrote in message ...
Hi,

I'm trying to do something similar. I have a sub which launches the
application we need to launch.

I can manually attach this to a button in a toolbar, but we want to roll
this out to all users in the organisation. Is there some VBScript style code
we can run on login which will add the button and the appropriate _click code
to their workstation?

Thanks,
Carl

  #7  
Old January 30th 07, 08:28 AM posted to microsoft.public.outlook.program_vba
Matt
external usenet poster
 
Posts: 119
Default Create a custom toolbar

I'm trying to use this code. Where do I make changes to link the button to
the macro? Is it possible to assign an icon to the button? I have two
macros, so I would like two buttons is this possible?

In the button part of the script, do I need to add some code where the ' is?

I have no experience with this sorry to be a burden!

Matt

"Michael Bauer" wrote:

Am Tue, 28 Feb 2006 14:02:31 -0800 schrieb Rhonda:

You can create a CommandBar by code. Here´s a sample. You can call the
CreateCommandBarButton function from within the NewInspector event. For the
ability to use more than one Inspector at once you´d need an Inspector
wrapper; a sample is at:
http://www.slovaktech.com/code_sampl...spectorWrapper

Private WithEvents Button As Office.CommandBarButton

Private Sub Button_Click(ByVal Ctrl As Office.CommandBarButton,
CancelDefault As Boolean)
'
End Sub

Private Function CreateCommandBarButton(oBars As Office.CommandBars) As
Office.CommandBarButton
On Error Resume Next
Dim oMenu As Office.CommandBar
Dim oBtn As Office.CommandBarButton
Const BAR_NAME As String = "YourCommandBarName"
Const CMD_NAME As String = "YourButtonName"

Set oMenu = oBars(BAR_NAME)
If oMenu Is Nothing Then
Set oMenu = oBars.Add(BAR_NAME, msoBarTop, , True)
Set oBtn = oMenu.Controls.Add(msoControlButton, , CMD_NAME, , True)
oBtn.Caption = CMD_NAME
oBtn.Tag = CMD_NAME

Else
Set oBtn = oMenu.FindControl(, , CMD_NAME)
If oBtn Is Nothing Then
Set oBtn = oMenu.Controls.Add(msoControlButton, , CMD_NAME, , True)
End If
End If

oMenu.Visible = True
Set CreateCommandBarButton = oBtn
End Function
--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


I have a macro to insert text in the subject line and message box of a new
mail message. I can create a custom toolbar button on the new mail

message
Standard toolbar. I know that I can save the VBProject.OTM on the

person's
hard drive but they must assign the toolbar button. The question I have

is
if there is a way to distribute this solution to other users without them
having to assign the macro to a toolbar?


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Toolbar button to evoke a custom view ? [email protected] Outlook - General Queries 1 March 20th 06 01:30 PM
create shortcut to folder in outlook toolbar [email protected] Outlook - General Queries 1 February 15th 06 04:16 PM
create shortcut to folder in outlook toolbar [email protected] Outlook - General Queries 0 February 14th 06 09:10 PM
MSG Custom properties on right click custom tab [email protected] Add-ins for Outlook 1 February 1st 06 06:00 PM
MSG Custom properties on right click custom tab Steph Outlook and VBA 1 February 1st 06 05:55 PM


All times are GMT +1. The time now is 02:07 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.