![]() |
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. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
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 |