Hay una macro que hace esto, lo descarge de la página de Ivan F. Moala
y es el siguiente:
//ThisWorkbook
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
ChangeTab_Colour
End Sub
//Module
'// API's for System Colours
Private Declare Function GetSysColor Lib "user32" ( _
ByVal nIndex As Long) As Long
Private Declare Function SetSysColors Lib "user32" ( _
ByVal nChanges As Long, _
lpSysColor As Long, _
lpColorValues As Long) As Long
'// Define Colour Constant
Private Const COLOR_WINDOW = 5
Sub ChangeTab_Colour()
Dim Kolor As Long
Dim CurKolor As Long
Dim R As Integer, G As Integer, B As Integer
'// Initialize random-number generator.
Randomize
'// Generate random value between 0 and 255.
R = Int(255 * Rnd)
G = Int(255 * Rnd)
B = Int(255 * Rnd)
'// Try these if you want Basic Colours
'// ===============================================
'// Black 0 0 0 || Blue 0 0 255
'// Green 0 255 0 || Cyan 0 255 255
'// Red 255 0 0 || Magenta 255 0 255
'// Yellow 255 255 0 || White 255 255 255
'// ===============================================
CurKolor = GetSysColor(COLOR_WINDOW)
With Application
.ScreenUpdating = False
'// color it Randomly
Kolor = SetSysColors(1, COLOR_WINDOW, RGB(R, G, B))
ShSet
.ScreenUpdating = True
MsgBox "Tab colour has changed!", vbInformation + vbSystemModal, "Tab Colour Hack "
.ScreenUpdating = False
ShReset
'// Restore to Default
Kolor = SetSysColors(1, COLOR_WINDOW, CurKolor)
.ScreenUpdating = True
End With
End Sub
Sub ShSet()
Dim x As Double
Cells.Select
With Selection
.Interior.ColorIndex = 2
.Interior.Pattern = xlSolid
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
End With
For x = 7 To 12
With Selection.Borders(x)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 15
End With
Next
[A1].Select
End Sub
Sub ShReset()
Cells.Select
With Selection
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
.Borders(xlEdgeLeft).LineStyle = xlNone
.Borders(xlEdgeTop).LineStyle = xlNone
.Borders(xlEdgeBottom).LineStyle = xlNone
.Borders(xlEdgeRight).LineStyle = xlNone
.Borders(xlInsideVertical).LineStyle = xlNone
.Borders(xlInsideHorizontal).LineStyle = xlNone
.Interior.ColorIndex = xlNone
End With
[A1].Select
End Sub
Se puede hacer que solo se ejecute a las barras de herramientas, menus y
submenus y no a las celdas y pestaña de la hoja ni al sistema de windows
(si se puede) cuando se valla al explorador u otro programa en ejecución?
(ya se que pido mucho pero no esta demás preguntar)