Toggling The Gridline Display

The net effect is that when the user changes worksheets or workbooks, the following CheckGridlines procedure is executed. This procedure ensures that the check mark displayed on the GridLines menu option is in sync with the sheet.

Sub CheckGridlines()

Dim TG As CommandBarButton On Error Resume Next

Set TG = CommandBars(1).FindControl(Id:=30004). _

Controls("&GridLines") If ActiveWindow.DisplayGridlines Then

TG.State = msoButtonDown


TG.State = msoButtonUp End If End Sub

This procedure checks the active window and sets the State property of the menu item. If grid lines are displayed, it adds a check mark to the GridLines menu item. If grid lines are not displayed, it removes the check mark from the menu item.

0 0

Post a comment