G
Guest
Below is the code for a module I have based on Steven Roman's "Writing Excel
Macros with VBA". I now need to have a module that will take the data stored
in sheet3 and enable the toolbars I've disabled here.
Can I get some help on how I would read this data from sheet3 and enable the
toolbars?
Thanks in advance.
Hal
Option Explicit
Public Sub ListCmdBars()
Dim sType As String, cbar As CommandBar, rng As Range
Dim cbarCount As Integer, lRow As Long, lCol As Long
lRow = 2
lCol = 2
Sheets("Sheet3").Cells(lRow - 1, lCol - 1) = "Name" 'cbar.Name
Sheets("Sheet3").Cells(lRow - 1, lCol) = "Type" 'sType
Sheets("Sheet3").Cells(lRow - 1, lCol + 1) = "Visible" 'cbar.Visible
For Each cbar In Application.CommandBars
Select Case cbar.Type
Case msoBarTypeNormal 'A toolbar
sType = "Normal"
Case msoBarTypeMenuBar 'A menu bar
sType = "Menu Bar"
Case msoBarTypePopup 'Menu, Submenu
sType = "Popup"
End Select
If cbar.Visible = True Then
Sheets("Sheet3").Cells(lRow, lCol - 1) = cbar.Name
Sheets("Sheet3").Cells(lRow, lCol) = sType
Sheets("Sheet3").Cells(lRow, lCol + 1) = cbar.Visible
cbar.Enabled = False
lRow = lRow + 1
End If
Next
End Sub
Macros with VBA". I now need to have a module that will take the data stored
in sheet3 and enable the toolbars I've disabled here.
Can I get some help on how I would read this data from sheet3 and enable the
toolbars?
Thanks in advance.
Hal
Option Explicit
Public Sub ListCmdBars()
Dim sType As String, cbar As CommandBar, rng As Range
Dim cbarCount As Integer, lRow As Long, lCol As Long
lRow = 2
lCol = 2
Sheets("Sheet3").Cells(lRow - 1, lCol - 1) = "Name" 'cbar.Name
Sheets("Sheet3").Cells(lRow - 1, lCol) = "Type" 'sType
Sheets("Sheet3").Cells(lRow - 1, lCol + 1) = "Visible" 'cbar.Visible
For Each cbar In Application.CommandBars
Select Case cbar.Type
Case msoBarTypeNormal 'A toolbar
sType = "Normal"
Case msoBarTypeMenuBar 'A menu bar
sType = "Menu Bar"
Case msoBarTypePopup 'Menu, Submenu
sType = "Popup"
End Select
If cbar.Visible = True Then
Sheets("Sheet3").Cells(lRow, lCol - 1) = cbar.Name
Sheets("Sheet3").Cells(lRow, lCol) = sType
Sheets("Sheet3").Cells(lRow, lCol + 1) = cbar.Visible
cbar.Enabled = False
lRow = lRow + 1
End If
Next
End Sub