シートのVBAコード
下記のVBAコードを追加してください。
Private Sub ExMouseDown(Btn As Integer, nno As Integer)
Dim sf As String
Dim ext As String
'右クリックの場合
If Btn = 2 Then
ButtonNo = nno
'ファイル指定フォームを開く
UserForm1.Show
'見出しをコマンドボタンに表示
Select Case nno
Case 1: CommandButton1.Caption = Range("AA" & ButtonNo)
CommandButton1.ForeColor = Range("AC" & ButtonNo)
Case 2: CommandButton2.Caption = Range("AA" & ButtonNo)
CommandButton2.ForeColor = Range("AC" & ButtonNo)
Case 3: CommandButton3.Caption = Range("AA" & ButtonNo)
CommandButton3.ForeColor = Range("AC" & ButtonNo)
Case 4: CommandButton4.Caption = Range("AA" & ButtonNo)
CommandButton4.ForeColor = Range("AC" & ButtonNo)
Case 5: CommandButton5.Caption = Range("AA" & ButtonNo)
CommandButton5.ForeColor = Range("AC" & ButtonNo)
Case 6: CommandButton6.Caption = Range("AA" & ButtonNo)
CommandButton6.ForeColor = Range("AC" & ButtonNo)
Case 7: CommandButton7.Caption = Range("AA" & ButtonNo)
CommandButton7.ForeColor = Range("AC" & ButtonNo)
Case 8: CommandButton8.Caption = Range("AA" & ButtonNo)
CommandButton8.ForeColor = Range("AC" & ButtonNo)
Case 9: CommandButton9.Caption = Range("AA" & ButtonNo)
CommandButton9.ForeColor = Range("AC" & ButtonNo)
Case 10: CommandButton10.Caption = Range("AA" & ButtonNo)
CommandButton10.ForeColor = Range("AC" & ButtonNo)
Case 11: CommandButton11.Caption = Range("AA" & ButtonNo)
CommandButton11.ForeColor = Range("AC" & ButtonNo)
Case 12: CommandButton12.Caption = Range("AA" & ButtonNo)
CommandButton12.ForeColor = Range("AC" & ButtonNo)
Case 13: CommandButton13.Caption = Range("AA" & ButtonNo)
CommandButton13.ForeColor = Range("AC" & ButtonNo)
End Select
Else
sf = Range("AB" & nno)
ext = ExGetExt(sf)
ExFileOpen LCase(ext), sf
End If
End Sub
'コマンドボタン クリックイベント
Private Sub CommandButton1_MouseDown(ByVal Button As Integer, _
ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
ExMouseDown Button, 1
End Sub
Private Sub CommandButton10_MouseDown(ByVal Button As Integer, _
ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
ExMouseDown Button, 10
End Sub
Private Sub CommandButton11_MouseDown(ByVal Button As Integer, _
ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
ExMouseDown Button, 11
End Sub
Private Sub CommandButton12_MouseDown(ByVal Button As Integer, _
ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
ExMouseDown Button, 12
End Sub
Private Sub CommandButton13_MouseDown(ByVal Button As Integer, _
ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
ExMouseDown Button, 13
End Sub
Private Sub CommandButton2_MouseDown(ByVal Button As Integer, _
ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
ExMouseDown Button, 2
End Sub
Private Sub CommandButton3_MouseDown(ByVal Button As Integer, _
ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
ExMouseDown Button, 3
End Sub
Private Sub CommandButton4_MouseDown(ByVal Button As Integer, _
ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
ExMouseDown Button, 4
End Sub
Private Sub CommandButton5_MouseDown(ByVal Button As Integer, _
ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
ExMouseDown Button, 5
End Sub
Private Sub CommandButton6_MouseDown(ByVal Button As Integer, _
ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
ExMouseDown Button, 6
End Sub
Private Sub CommandButton7_MouseDown(ByVal Button As Integer, _
ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
ExMouseDown Button, 7
End Sub
Private Sub CommandButton8_MouseDown(ByVal Button As Integer, _
ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
ExMouseDown Button, 8
End Sub
Private Sub CommandButton9_MouseDown(ByVal Button As Integer, _
ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
ExMouseDown Button, 9
End Sub
End Sub
シートとユーザーフォーム
「青色」ボタン - アプリケーションソフトの起動用
「緑色」ボタン - データファイルを開く
「赤色」ボタン - ホームページを開く