V
vicky
i have code which creates a combobox control on standard toolbar on
microsoft excel. i have a bug in this code ... dono where i have gone
wrong ..... hope anyone can help me with this ...
Option Explicit
Sub AddComboNavigation()
Dim cBar As CommandBar
Dim c As CommandBarComboBox
Dim i As Integer
‘ Set reference to standard toolbar
Set cBar = Application.CommandBars(“standard”)
cBar.Reset
‘Add Combobox Control
Set c = cBar.Controls.Add(msoControlComboBox, 1)
With c
.Clear
For i = 1 To ThisWorkbook.Sheets.Count
.AddItem ThisWorkbook.Sheets(i).Name, 1
Next i
.Caption = “Sheet Navigator”
.DescriptionText = “This is the area where you can place
description area”
.Enabled = True
.Visible = True
.DropDownLines = 5
.ListIndex = 0
.OnAction = “Activate_Sheet”
End With
End Sub
Private Sub Activate_Sheet()
‘on error resume next
Dim x As String
Dim c As CommandBarComboBox
Set c = Application.CommandBars(“standard”).Controls(“Sheet
Navigator”)
If c.ListIndex 0 Then
Sheets(c.ListCount – c.ListIndex + 1).Activate
End If
End Sub
microsoft excel. i have a bug in this code ... dono where i have gone
wrong ..... hope anyone can help me with this ...
Option Explicit
Sub AddComboNavigation()
Dim cBar As CommandBar
Dim c As CommandBarComboBox
Dim i As Integer
‘ Set reference to standard toolbar
Set cBar = Application.CommandBars(“standard”)
cBar.Reset
‘Add Combobox Control
Set c = cBar.Controls.Add(msoControlComboBox, 1)
With c
.Clear
For i = 1 To ThisWorkbook.Sheets.Count
.AddItem ThisWorkbook.Sheets(i).Name, 1
Next i
.Caption = “Sheet Navigator”
.DescriptionText = “This is the area where you can place
description area”
.Enabled = True
.Visible = True
.DropDownLines = 5
.ListIndex = 0
.OnAction = “Activate_Sheet”
End With
End Sub
Private Sub Activate_Sheet()
‘on error resume next
Dim x As String
Dim c As CommandBarComboBox
Set c = Application.CommandBars(“standard”).Controls(“Sheet
Navigator”)
If c.ListIndex 0 Then
Sheets(c.ListCount – c.ListIndex + 1).Activate
End If
End Sub