Với macro bên dưới, bạn có thể chuyển đổi tính khả dụng của Thanh menu sổ làm việc, thanh công cụ Chuẩn và Thanh lệnh tùy chỉnh.

Lần đầu tiên bạn chạy macro, menu và thanh Chuẩn bị tắt, thanh công cụ tùy chỉnh được bật.

Lần tới khi bạn chạy macro, menu và thanh Chuẩn được bật, Thanh lệnh tùy chỉnh sẽ bị tắt.

Sub ToggleCommandBars()

Dim cbEnabled As Boolean

' get the current commandbar state

cbEnabled = Not Application.CommandBars(1).Enabled

' apply the new state to the Workbook Menu Bar

Application.CommandBars(1).Enabled = cbEnabled

' apply the new state to the Standard toolbar

Application.CommandBars("StandardOPE").Enabled = cbEnabled

' apply the new state to a custom commandbar (the oposite of the previous two)

Application.CommandBars("MyCustomCommandBar").Enabled = Not cbEnabled

End Sub