I think this is it. It came from a previous post but I cant remember when.
This Workbook:
Option Explicit
Dim cControl As CommandBarButton
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Sheets("Sheet1").Select
End Sub
Private Sub Workbook_Open()
'Take away the Menu item for now
'Workbook_AddinInstall
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Workbook_AddinUninstall
End Sub
Private Sub Workbook_AddinInstall()
On Error Resume Next
Application.CommandBars("Worksheet Menu Bar").Controls("WB Navigator
..qx").Delete
Set cControl = Application.CommandBars("Worksheet Menu Bar").Controls.Add
With cControl
..Caption = "WB Navigator &q"
..Style = msoButtonCaption
..OnAction = "ShowWorkbooks"
End With
On Error GoTo 0
End Sub
Private Sub Workbook_AddinUninstall()
On Error Resume Next
Application.CommandBars("Worksheet Menu Bar").Controls("WB Navigator
q").Delete
On Error GoTo 0
End Sub
------------------------------------------------------------
Module:
Sub ShowWorkbooks()
Application.ScreenUpdating = False
Dim wb As Workbook
With UserForm1
..ListBox1.Clear
..ListBox2.Clear
For Each wb In Workbooks
.ListBox1.AddItem wb.Name
Next
Call SortListBox(.ListBox1)
.ListBox1.ListIndex = 0
.ListBox1.SetFocus
'MsgBox .ListBox1.Value
vListPosition = 0
Do Until .ListBox1.Value = ActiveWorkbook.Name
vListPosition = vListPosition + 1
.ListBox1.ListIndex = vListPosition
Loop
End With
UserForm1.Show False
End Sub
Sub SortListBox1(oLb As MSForms.ListBox)
Dim vaItems As Variant
Dim i As Long, j As Long
Dim vTemp As Variant
'Put the items in a variant array
vaItems = oLb.List
'Steal code from John Walkenbach’s Excel Power Programming
'with VBA to sort the array
For i = LBound(vaItems, 1) To UBound(vaItems, 1) - 1
For j = i + 1 To UBound(vaItems, 1)
If vaItems(i, 0) > vaItems(j, 0) Then
vTemp = vaItems(i, 0)
vaItems(i, 0) = vaItems(j, 0)
vaItems(j, 0) = vTemp
End If
Next j
Next i
'Clear the listbox
oLb.Clear
'Add the sorted array back to the listbox
'For i = LBound(vaItems, 1) To UBound(vaItems, 1)
' oLb.AddItem vaItems(i, 0)
'Next i
'This next code replace the above code by a Microsoft Group comment
04/18/08
oLb.List = vaItems
End Sub
Sub SortListBox(oLb As MSForms.ListBox)
Dim i As Long, j As Long
Dim vTemp As Variant
'with VBA to sort the array
For i = 0 To oLb.ListCount - 2
For j = i + 1 To oLb.ListCount - 1
If CStr(oLb.List(i, 0)) > CStr(oLb.List(j, 0)) Then
vTemp = CStr(oLb.List(i, 0))
oLb.List(i, 0) = CStr(oLb.List(j, 0))
oLb.List(j, 0) = vTemp
End If
Next j
Next i
End Sub