Display ToolTipText in CommandBar Controls
Sub Show_ToolTipText_In_Controls()
Dim oCB As CommandBar
Dim oCtl As CommandBarControl
On Error Resume Next
' Delete Existing Command Bar
CommandBars("MyProject").Delete
'Create New Command Bar
Set oCB = CommandBars.Add
oCB.Name = "MyProject"
oCB.AdaptiveMenu = True
Set oCtl = oCB.Controls.Add(Type:=msoControlButton)
oCtl.Caption = "Show Message Box"
oCtl.TooltipText = "This is a sample"
oCtl.OnAction = "Display_Msg_Box"
oCtl.SetFocus
' Show the Command Bar
oCB.Visible = True
' Place the CommandBar at the bottom of the screen
oCB.Position = msoBarBottom
End Sub
Sub Display_Msg_Box()
MsgBox "You have clicked me!!!"
End Sub
Showing posts with label Add Command to Tools menu. Show all posts
Showing posts with label Add Command to Tools menu. Show all posts
Monday, May 07, 2007
Tuesday, April 17, 2007
Add Controls To Tools Menu
Creating Custom Office Menus and Toolbars
Sub Call_Add_Control_To_ToolsMenu()
' ---------------------------------------------------------------
' Written By Shanmuga Sundara Raman for http://vbadud.blogspot.com
' ---------------------------------------------------------------
Add_Control_To_ToolsMenu "Sample", "Donot_Fire_Events"
End Sub
you need to have a sub Donot_Fire_Events to test this
Function Add_Control_To_ToolsMenu(ByVal sControlName As String, ByVal sMacroName As String)
' ---------------------------------------------------------------
' Written By Shanmuga Sundara Raman for http://vbadud.blogspot.com
' ---------------------------------------------------------------
On Error GoTo DisplayErr
Dim ctlMenu As CommandBarControl
Dim ctlCommand As CommandBarControl
Set ctlMenu = Application.CommandBars.FindControl(ID:=30007)
If ctlMenu Is Nothing Then Exit Function
Set ctlCommand = ctlMenu.Controls.Add
ctlCommand.Caption = sControlName
ctlCommand.OnAction = sMacroName
DisplayErr:
If Err <> 0 Then
MsgBox Err.Description
Err.Clear
End If
Creating Custom Office Menus and Toolbars, Programming Microsoft Office Command Bars, CommandBars Property, Creating an Excel Add-in, Disable command bars and controls, Change the availability for the CommandBars using VBA, Delete/ hide a custom command bar
Add a new menu item to the Tools menu, Adding Menu Items, Add Command to Tools menu, Dynamic Addition of command to tools menu. Adding Command Button to Tools, Adding to Tools menu
End Function
Sub Call_Add_Control_To_ToolsMenu()
' ---------------------------------------------------------------
' Written By Shanmuga Sundara Raman for http://vbadud.blogspot.com
' ---------------------------------------------------------------
Add_Control_To_ToolsMenu "Sample", "Donot_Fire_Events"
End Sub
you need to have a sub Donot_Fire_Events to test this
Function Add_Control_To_ToolsMenu(ByVal sControlName As String, ByVal sMacroName As String)
' ---------------------------------------------------------------
' Written By Shanmuga Sundara Raman for http://vbadud.blogspot.com
' ---------------------------------------------------------------
On Error GoTo DisplayErr
Dim ctlMenu As CommandBarControl
Dim ctlCommand As CommandBarControl
Set ctlMenu = Application.CommandBars.FindControl(ID:=30007)
If ctlMenu Is Nothing Then Exit Function
Set ctlCommand = ctlMenu.Controls.Add
ctlCommand.Caption = sControlName
ctlCommand.OnAction = sMacroName
DisplayErr:
If Err <> 0 Then
MsgBox Err.Description
Err.Clear
End If
Creating Custom Office Menus and Toolbars, Programming Microsoft Office Command Bars, CommandBars Property, Creating an Excel Add-in, Disable command bars and controls, Change the availability for the CommandBars using VBA, Delete/ hide a custom command bar
Add a new menu item to the Tools menu, Adding Menu Items, Add Command to Tools menu, Dynamic Addition of command to tools menu. Adding Command Button to Tools, Adding to Tools menu
End Function
Subscribe to:
Posts (Atom)
Download Windows Live Toolbar and personalize your Web experience! Add custom buttons to get the information you care about most.