bigdan43
08-25-2008, 12:41 PM
I'd like to create a custom toolbar in outlook (which isn't difficult).
However, I would like there to be a textbox on the toolbar as well (like outlook has for address book searches).
Is this possible, and can my toolbar buttons interact with the textbox?
My toolbar will require the user to enter a file number and then click a button. The macro tied to that button will be dependant on the text entered in the box.
I found an addin for vs2008 that does just that but it costs 3-800$ per liscence to let you make controls using .net.
*****EDIT
I seem to have figured out how to add a combobox... it doesn't look like a text box is possible.
Private Sub Application_Startup()
'Adds a custom button to the standard toolbar if it's not there already.
'Clicking on this button calls a custom action that would have to be
'defined in a separate sub, see the .OnAction line below.
Dim cbb As CommandBarComboBox
Dim cbStandard As CommandBar
Dim cbExist As Boolean
'The Standard toolbar is the one with "New", "Send/Receive", etc on it.
Set cbStandard = ActiveExplorer.CommandBars("Standard")
cbExist = IsMenuThere("Standard", "CustomButton")
'If the option is not already on the menu, add it
If cbExist = False Then
Set cbb = cbStandard.Controls.Add(Type:=msoControlComboBox, Before:=1)
cbb.Caption = "Custom&Button"
cbb.OnAction = "NameOfFunctionToCallOnClick"
cbb.TooltipText = "Tooltip for this button"
End If
Set cbb = Nothing
Set cbEdit = Nothing
Set cbStandard = Nothing
End Sub
Public Function IsMenuThere(sMenu As String, sName As String) As Boolean
'Returns true if menu sName exists in sMenu
Dim cbb As CommandBar
Dim cbControl As CommandBarControl
IsMenuThere = False
Set cbb = ActiveExplorer.CommandBars(sMenu)
'Cycles through the given commandbar, checking the captions to see
'if they match the one we're looking for
For Each cbControl In cbb.Controls
If cbControl.Caption = sName Then
IsMenuThere = True
Exit Function
End If
Next
Set cbb = Nothing
Set cbControl = Nothing
End Function
However, I would like there to be a textbox on the toolbar as well (like outlook has for address book searches).
Is this possible, and can my toolbar buttons interact with the textbox?
My toolbar will require the user to enter a file number and then click a button. The macro tied to that button will be dependant on the text entered in the box.
I found an addin for vs2008 that does just that but it costs 3-800$ per liscence to let you make controls using .net.
*****EDIT
I seem to have figured out how to add a combobox... it doesn't look like a text box is possible.
Private Sub Application_Startup()
'Adds a custom button to the standard toolbar if it's not there already.
'Clicking on this button calls a custom action that would have to be
'defined in a separate sub, see the .OnAction line below.
Dim cbb As CommandBarComboBox
Dim cbStandard As CommandBar
Dim cbExist As Boolean
'The Standard toolbar is the one with "New", "Send/Receive", etc on it.
Set cbStandard = ActiveExplorer.CommandBars("Standard")
cbExist = IsMenuThere("Standard", "CustomButton")
'If the option is not already on the menu, add it
If cbExist = False Then
Set cbb = cbStandard.Controls.Add(Type:=msoControlComboBox, Before:=1)
cbb.Caption = "Custom&Button"
cbb.OnAction = "NameOfFunctionToCallOnClick"
cbb.TooltipText = "Tooltip for this button"
End If
Set cbb = Nothing
Set cbEdit = Nothing
Set cbStandard = Nothing
End Sub
Public Function IsMenuThere(sMenu As String, sName As String) As Boolean
'Returns true if menu sName exists in sMenu
Dim cbb As CommandBar
Dim cbControl As CommandBarControl
IsMenuThere = False
Set cbb = ActiveExplorer.CommandBars(sMenu)
'Cycles through the given commandbar, checking the captions to see
'if they match the one we're looking for
For Each cbControl In cbb.Controls
If cbControl.Caption = sName Then
IsMenuThere = True
Exit Function
End If
Next
Set cbb = Nothing
Set cbControl = Nothing
End Function