Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" _ (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, _ ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long Private Declare Function GetAsyncKeyState Lib "User32.dll" (ByVal vKey As Long) As Long Public now_row As Integer Sub PlaySound(tmp_start As Variant) Dim SoundFile As String 'サウンドファイル名 Dim start As Integer '再生開始地点 Dim ptime As Integer '再生時間 Dim rc As Long 'MCIの返り値 '値が数値以外なら終わり If Not IsNumeric(tmp_start) Then Exit Sub End If '値が0〜30以外だったら終わり If tmp_start < 0# Or tmp_start > 30# Then Exit Sub End If SoundFile = Range("A1").Value 'WAVEファイル名をA1から取得 ptime = Range("B1").Value '再生時間(開始地点から何秒再生するか)をB1から取得(ms単位) '秒をミリ秒に変換 start = CInt(tmp_start * 1000) 'WAVEファイル存在チェック If Dir(SoundFile) = "" Then MsgBox SoundFile & vbCrLf & "がありません。", vbExclamation Exit Sub End If '再生APIコール mci_str = "Play " & SoundFile & " from " & start & " to " & start + ptime rc = mciSendString(mci_str, "", 0, 0) End Sub 'セルダブルクリックイベント Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) End Sub '右クリックイベント Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean) Cancel = True If Target.Column() <> 5 Then Exit Sub End If Dim offset As Integer Dim str As String offset = 0 '空白でないセルを探す Do While Cells(Target.Row() - offset, Target.Column()) = "" offset = offset + 1 If (Target.Row() - offset) < 0 Then Exit Sub End If Loop str = Cells(Target.Row() - offset, Target.Column()) '間を埋める For i = offset To 0 Step -1 Cells(Target.Row() - i, Target.Column()) = str Next End Sub 'セル移動イベント Private Sub Worksheet_SelectionChange(ByVal Target As Range) '飛ばすコマ数を取得 Dim offset As Integer offset = Range("C1").Value If Not IsNumeric(offset) Then offset = 1 End If '「無変換」キー押下時のみ処理 If GetAsyncKeyState(29) <> 0 Then If now_row = Target.Row() - 1 Then ActiveCell.offset(offset).Activate Exit Sub End If If now_row = Target.Row() + 1 Then ActiveCell.offset(-offset).Activate Exit Sub End If End If now_row = Target.Row() PlaySound (Cells(Target.Row(), 2).Value) End Sub