Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default Error with combobox control on standard toolbar

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(“Shee t
Navigator”)
If c.ListIndex 0 Then
Sheets(c.ListCount – c.ListIndex + 1).Activate
End If
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Error with combobox control on standard toolbar


See comments in code below

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
'added before
Set c = cBar.Controls.Add(Type:=msoControlComboBox, ID:=1, befo=1)
With c
.Clear
For i = 1 To ThisWorkbook.Sheets.Count
'changes 1 to i
.AddItem ThisWorkbook.Sheets(i).Name, i
Next i
.Caption = "Sheet Navigator"
.DescriptionText = "This is the area where you can place " & _
"Description area"
.Enabled = True
.Visible = True
'add line
.DropDownLines = Sheets.Count
.ListIndex = 0
'add line
.DropDownWidth = 75
.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("Shee t
Navigator")

If c.ListIndex < 0 Then
'changed parameter to select sheet
Sheets(c.ListIndex).Activate
End If
End Sub

See comments in code below


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
'added before
Set c = cBar.Controls.Add(Type:=msoControlComboBox, ID:=1, befo=1)
With c
.Clear
For i = 1 To ThisWorkbook.Sheets.Count
'changes 1 to i
.AddItem ThisWorkbook.Sheets(i).Name, i
Next i
.Caption = "Sheet Navigator"
.DescriptionText = "This is the area where you can place " & _
"Description area"
.Enabled = True
.Visible = True
'add line
.DropDownLines = Sheets.Count
.ListIndex = 0
'add line
.DropDownWidth = 75
.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("Shee t
Navigator")

If c.ListIndex < 0 Then
'changed parameter to select sheet
Sheets(c.ListIndex).Activate
End If
End Sub


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=164699

Microsoft Office Help

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Assign Error message to Standard toolbar icon Learning Excel Discussion (Misc queries) 0 January 14th 10 12:57 AM
Standard Toolbar ksal Excel Discussion (Misc queries) 3 January 6th 10 03:57 PM
Changes to standard toolbar Alison Excel Discussion (Misc queries) 5 May 15th 06 11:44 PM
toolbar for "standard tickmarks" mark kubicki Excel Worksheet Functions 0 July 12th 05 07:16 PM
Hiding the Standard Toolbar Andy T Excel Discussion (Misc queries) 2 December 15th 04 05:25 PM


All times are GMT +1. The time now is 01:50 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"