Results 1 to 9 of 9

Auto Update Navigation Toolbar

Threaded View

pr4t3ek Auto Update Navigation Toolbar 01-25-2009, 05:31 AM
royUK There's a free navigation... 01-25-2009, 05:38 AM
pr4t3ek i dont want an add-in because... 01-25-2009, 05:43 AM
royUK When wold you want to refresh... 01-25-2009, 07:00 AM
pr4t3ek Re: Auto Update Navigation... 01-26-2009, 08:37 AM
royUK Re: Auto Update Navigation... 01-26-2009, 08:40 AM
pr4t3ek Re: Auto Update Navigation... 01-26-2009, 08:44 AM
royUK Re: Auto Update Navigation... 01-26-2009, 08:52 AM
pr4t3ek Re: Auto Update Navigation... 01-26-2009, 11:03 PM
  1. #1
    Forum Contributor pr4t3ek's Avatar
    Join Date
    10-13-2008
    Location
    Melbourne, Australia
    MS-Off Ver
    2003 & 2007, 2010
    Posts
    483

    Auto Update Navigation Toolbar

    Hi,
    I have the following code
    Sub Auto_Close()
    On Error Resume Next
    Application.CommandBars("Daily Backlog/Inflow Navigation Toolbar").Delete
    On Error GoTo 0
    End Sub
    Sub Auto_Open()
    'code written by Pratik Dhody
    
    Dim cb As CommandBar
    Dim ctrl As CommandBarControl
    
    On Error Resume Next
    Application.CommandBars("Daily Backlog/Inflow Navigation Toolbar").Delete
    On Error GoTo 0
    
    Set cb = Application.CommandBars.Add(Name:="Daily Backlog/Inflow Navigation Toolbar", temporary:=True)
    With cb
    .Visible = True
    
    Set ctrl = .Controls.Add(Type:=msoControlButton, temporary:=True)
    With ctrl
    .Style = msoButtonCaption
    .Caption = "Refresh Worksheet List"
    .OnAction = ThisWorkbook.Name & "!refreshthesheets"
    End With
    
    Set ctrl = .Controls.Add(Type:=msoControlComboBox, temporary:=True)
    With ctrl
    .Width = 300
    .AddItem "Click Refresh First"
    .OnAction = ThisWorkbook.Name & "!changethesheet"
    .Tag = "__wksnames__"
    End With
    End With
    End Sub
    Sub ChangeTheSheet()
    Dim myWksName As String
    Dim wks
    With Application.CommandBars.ActionControl
    If .ListIndex = 0 Then
    MsgBox "Please select an existing sheet"
    Exit Sub
    Else
    myWksName = .List(.ListIndex)
    End If
    End With
    
    Set wks = Nothing
    On Error Resume Next
    Set wks = Sheets(myWksName)
    On Error GoTo 0
    
    If wks Is Nothing Then
    Call RefreshTheSheets
    MsgBox "Please try again"
    Else
    wks.Select
    End If
    End Sub
    Sub RefreshTheSheets()
    Dim ctrl As CommandBarControl
    Dim wks
    
    Set ctrl = Application.CommandBars("Daily Backlog/Inflow Navigation Toolbar") _
    .FindControl(Tag:="__wksnames__")
    ctrl.Clear
    
    For Each wks In ActiveWorkbook.Sheets
    If wks.Visible = xlSheetVisible Then
    ctrl.AddItem wks.Name
    End If
    Next wks
    End Sub
    how can i amend it to automatically update the toolbar with all the sheets in the toolbar, isntead of having to click on "Referesh Worksheet list"

    cheers
    Last edited by pr4t3ek; 01-26-2009 at 11:03 PM.
    --
    Regards
    PD

    ----- Don't Forget -----

    1. Use code tags. Place "[code]" before the first line of code and "[/code"]" after the last line of code. Exclude quotation marks

    2. Thank those who have helped you by Clicking the scales above each post.

    3. Please mark your post [SOLVED] if it has been answered satisfactorily.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1