|
▼ペーターパン さん:
試したのは、こんな感じです。
Option Explicit
Dim WithEvents xlApp As Application
Dim bLine As Range
Private Sub Workbook_Open()
Set xlApp = Application
With xlApp.CommandBars("Cell").Controls.Add(before:=1)
.Caption = "強調表示OFF"
.OnAction = "thisworkbook.メニュ切り替え"
ThisWorkbook.Sheets(1).Cells(1).Value = False
End With
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Not bLine Is Nothing Then bLine.Font.Bold = False
xlApp.CommandBars("Cell").Controls(1).Delete
End Sub
Private Sub メニュ切り替え()
With ThisWorkbook.Sheets(1).Cells(1)
If .Value = False Then
xlApp.CommandBars("Cell").Controls(1).Caption = "強調表示ON"
Else
xlApp.CommandBars("Cell").Controls(1).Caption = "強調表示OFF"
End If
.Value = Not .Value
End With
End Sub
Private Sub xlApp_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
If Not bLine Is Nothing Then
bLine.Font.Bold = False
Set bLine = Nothing
End If
If ThisWorkbook.Sheets(1).Cells(1).Value Then
Selection.EntireRow.Font.Bold = True
Set bLine = Selection.EntireRow
End If
End Sub
|
|