VBA/Excel/Access/Word/Excel/Excel Toolbar

Материал из VB Эксперт
Перейти к: навигация, поиск

Hide All Toolbars

 
Sub HideAllToolbars()
    Dim TB As CommandBar
    Dim TBNum As Integer
    Dim mySheet As Worksheet
    Set mySheet = Sheets("mySheet")
    Application.ScreenUpdating = False
    mySheet.Cells.Clear
    
    TBNum = 0
    For Each TB In CommandBars
        If TB.Type = msoBarTypeNormal Then
            If TB.Visible Then
                TBNum = TBNum + 1
                TB.Visible = False
                mySheet.Cells(TBNum, 1) = TB.Name
            End If
        End If
    Next TB
    Application.ScreenUpdating = True
End Sub



Restore Toolbars

 
Sub RestoreToolbars()
    Dim mySheet As Worksheet
    Set mySheet = Sheets("mySheet")
    Application.ScreenUpdating = False
    On Error Resume Next
    For Each cell In mySheet.Range("A:A").SpecialCells(xlCellTypeConstants)
        CommandBars(cell.Value).Visible = True
    Next cell
    Application.ScreenUpdating = True
End Sub