Option Explicit 'VBE メニューをリスティング Sub VbeMenuList() Dim mn As Variant Dim ctrl1 As Variant Dim ctrl2 As Variant Dim flg1 As Boolean Dim flg2 As Boolean Dim i As Integer Dim s As Integer Dim j As Integer Dim width1 As Integer Dim width2 As Integer Dim width3 As Integer On Error Resume Next Worksheets("Excelメニューリスト" & IIf(XlsVer >= "9", "2k", "97")).Select Cells.Select Selection.Delete Shift:=xlUp Cells(1, 1).Select 'Application.CommandBarsにすればExcelのメニュー For Each mn In Application.VBE.CommandBars i = i + 1 j = Len(mn.Name) If width1 < j Then width1 = j Cells(i, 1) = mn.Name flg1 = True For Each ctrl1 In mn.Controls If flg1 = False Then i = i + 1 flg1 = False j = Len(ctrl1.Caption) If width2 < j Then width2 = j Cells(i, 2) = ctrl1.Caption s = ctrl1.Controls.Count If Err = 0 And s > 0 Then flg2 = True For Each ctrl2 In ctrl1.Controls If flg2 = False Then i = i + 1 flg2 = False j = Len(ctrl2.Caption) If width3 < j Then width3 = j Cells(i, 3) = ctrl2.Caption Next End If Err.Clear Next Next Columns("A:A").Select Selection.ColumnWidth = width1 Columns("B:B").Select Selection.ColumnWidth = width2 Columns("C:C").Select Selection.ColumnWidth = width3 Cells(1, 1).Select Worksheets("コマンド").Select End Sub 'オブジェクト ブラウザ Sub VbeCompile() Dim ctrl As Object Set ctrl = Application.VBE.CommandBars("メニュー バー").Controls(3).Controls(5) ctrl.Execute Set ctrl = Nothing End Sub 'VBE 保存 ctrl.caption Sub VbeSave() Dim ctrl As Object Set ctrl = Application.VBE.CommandBars("メニュー バー").Controls(1).Controls(IIf(XlsVer >= "9", 3, 1)) ctrl.Execute Set ctrl = Nothing End Sub 'Excel メニューをリスティング Sub ExcelMenuList() Dim mn As Variant Dim ctrl1 As Variant Dim ctrl2 As Variant Dim flg1 As Boolean Dim flg2 As Boolean Dim i As Integer Dim s As Integer Dim j As Integer Dim width1 As Integer Dim width2 As Integer Dim width3 As Integer On Error Resume Next Worksheets("Excelメニューリスト" & IIf(XlsVer >= "9", "2k", "97")).Select Cells.Select Selection.Delete Shift:=xlUp Cells(1, 1).Select 'Application.VBE.CommandBarsにすればVisual Basic Editorのメニュー For Each mn In Application.CommandBars i = i + 1 j = Len(mn.Name) If width1 < j Then width1 = j Cells(i, 1) = mn.Name flg1 = True For Each ctrl1 In mn.Controls If flg1 = False Then i = i + 1 flg1 = False j = Len(ctrl1.Caption) If width2 < j Then width2 = j Cells(i, 2) = ctrl1.Caption s = ctrl1.Controls.Count If Err = 0 And s > 0 Then flg2 = True For Each ctrl2 In ctrl1.Controls If flg2 = False Then i = i + 1 flg2 = False j = Len(ctrl2.Caption) If width3 < j Then width3 = j Cells(i, 3) = ctrl2.Caption Next End If Err.Clear Next Next Columns("A:A").Select Selection.ColumnWidth = width1 Columns("B:B").Select Selection.ColumnWidth = width2 Columns("C:C").Select Selection.ColumnWidth = width3 Cells(1, 1).Select Worksheets("コマンド").Select End Sub 'Excel 開く Sub ExcelFileOpen() Dim ctrl As Object Set ctrl = Application.CommandBars("Worksheet Menu Bar").Controls(1).Controls(2) ctrl.Execute Set ctrl = Nothing End Sub 'Excel ヘルプ Sub ExcelHelp() Dim ctrl As Object Set ctrl = Application.CommandBars("Worksheet Menu Bar").Controls(10).Controls(1) ctrl.Execute Set ctrl = Nothing End Sub Private Function XlsVer() As String XlsVer = Application.Version End Function