Ayuda con macro Navigate

roberto

New Member
Joined
Aug 28, 2002
Messages
43
Como puedo hacer para que esta macro funcione en cualquier libro que tenga activo y haga referencia a las hojas que tenga ese libro?


en el modulo ThisWorkbook:
Public Sub Navigate()
Dim ac As CommandBarButton
Set ac = Application.CommandBars.ActionControl
Sheets(ac.Caption).Select
Set ac = Nothing
End Sub
Private Sub Workbook_Deactivate()
Application.CommandBars("Cell").Reset
End Sub
Private Sub Workbook_Activate()
CreatePopUp
End Sub


en un modulo normal:

Sub CreatePopUp() ' creates the custom popup menu
Dim cb As CommandBar, i As Integer
Set cb = Application.CommandBars("Cell")
With cb
.Reset
For i = 1 To Sheets.Count
With .Controls.Add(Type:=msoControlButton)
.OnAction = "ThisWorkBook.Navigate"
.FaceId = 0
.Caption = Sheets(i).Name
.TooltipText = "Ir a esta hoja: " & Sheets(i).Name
End With
Next
End With
Set cb = Nothing
End Sub
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Si usted está trabajando en XL2002 (no sé sobre versiones anteriores) usted puede hacer un "click-derecho" con el cursor sobre las flechitas que aparecen a la izquierda de las etiquetas (tabs) de las hojas y automaticamente aparece un menu con todas las hojas disponibles. Si quiere duplicar esta función en una versión anterior de Excel, creo que sería necesario hacer un Class Module de tipo aplicación y poner programación que ejecuta durante eventos WB_Activate y WB_Deactivate.

Saludos,
 
Upvote 0

Forum statistics

Threads
1,223,941
Messages
6,175,536
Members
452,652
Latest member
eduedu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top