- ©«¤l
- 109
- ¥DÃD
- 2
- ºëµØ
- 0
- ¿n¤À
- 114
- ÂI¦W
- 0
- §@·~¨t²Î
- Win7 Win10
- ³nÅ骩¥»
- Office 2019 WPS
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ²`¦`
- µù¥U®É¶¡
- 2013-2-2
- ³Ì«áµn¿ý
- 2024-11-6
|
¦^´_ 1# lshsien
²K¥[¤@Ó·sªº¼Ò¶ô¡A±N¤U±ªº¥N½XÖ߶K¨ì¦¹¼Ò¶ô¤¤¡G- Option Explicit
- #If VBA7 Then
- Private Declare PtrSafe Function waveOutGetNumDevs Lib "winmm.dll" () As Long
- Private Declare PtrSafe Function mciSendString Lib "winmm.dll" Alias "mciSendStringW" (ByVal lpstrCommand As LongPtr, ByVal lpstrRetumString As LongPtr, ByVal uReturnLength As Long, ByVal hwndCallback As LongPtr) As Long
- Private Declare PtrSafe Function GetShortPathNameW Lib "kernel32" (ByVal lpszLongPath As LongPtr, ByVal lpszShortPath As LongPtr, ByVal cchBuffer As Long) As Long
- Private Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
- Private Declare PtrSafe Function PathFindExtension Lib "shlwapi.dll" Alias "PathFindExtensionW" (ByVal pszPath As LongPtr) As LongPtr
- Private Declare PtrSafe Function lStrLen Lib "kernel32.dll" Alias "lstrlenW" (ByVal lpString As LongPtr) As Long
- Private Declare PtrSafe Sub CopyMemoryByPtr Lib "kernel32.dll" Alias "RtlMoveMemory" (ByVal Destination As LongPtr, ByVal Source As LongPtr, ByVal Length As Long)
- #Else
- Private Declare Function waveOutGetNumDevs Lib "winmm.dll" () As Long
- Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringW" (ByVal lpstrCommand As Long, ByVal lpstrRetumString As Long, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
- Private Declare Function GetShortPathNameW Lib "kernel32" (ByVal lpszLongPath As Long, ByVal lpszShortPath As Long, ByVal cchBuffer As Long) As Long
- Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
- Private Declare Function PathFindExtension Lib "shlwapi.dll" Alias "PathFindExtensionW" (ByVal pszPath As Long) As Long
- Private Declare Function lStrLen Lib "kernel32.dll" Alias "lstrlenW" (ByVal lpString As Long) As Long
- Private Declare Sub CopyMemoryByPtr Lib "kernel32.dll" Alias "RtlMoveMemory" (ByVal Destination As Long, ByVal Source As Long, ByVal Length As Long)
- #End If
- Private Type FileList
- FileName As String
- ShortName As String
- End Type
- Private FileList() As FileList
- Private ListCount As Long
- Public Sub Clean()
- ListCount = 0
- Erase FileList
- End Sub
- Public Property Get Item(ByVal Index As Long) As String
- If Index > 0 And Index <= ListCount Then
- Item = FileList(Index).FileName
- End If
- End Property
- Public Property Let Item(ByVal Index As Long, ByVal FileName As String)
- Dim I As Long
- If Index = ListCount + 1 Then
- ListCount = ListCount + 1
- ReDim Preserve FileList(1 To ListCount)
- End If
- If (Index > 0) And (Index <= ListCount) Then
- With FileList(Index)
- .FileName = FileName
-
- I = Len(FileName)
- If I > 0 Then
- .ShortName = GetShortPathName(FileName)
- Else
- .ShortName = vbNullString
- End If
- End With
- End If
- End Property
- Public Function ItemAdd(ByVal FileName As String) As Long
- Dim I As Long
- I = ListCount + 1
- Item(I) = FileName
- ItemAdd = I
- End Function
- Public Function ItemReMove(ByVal Index As Long) As Boolean
- If Index > 0 And Index <= ListCount Then
- With FileList(Index)
- .FileName = vbNullString
- .ShortName = vbNullString
- End With
- End If
- End Function
- Public Sub StartPlay()
- Dim I As Long
-
- If waveOutGetNumDevs > 0 Then
- For I = 1 To ListCount Step 1
- With FileList(I)
- If Len(.ShortName) Then
- Select Case UCase$(ExtractFileExtension(.ShortName))
- Case ".WAV": mciSendString StrPtr("open " & .ShortName & " type waveaudio alias JofornMusic"), 0, 0, 0
- Case ".MDI": mciSendString StrPtr("open " & .ShortName & " type sequencer alias JofornMusic"), 0, 0, 0
- Case Else: mciSendString StrPtr("open " & .ShortName & " alias JofornMusic"), 0, 0, 0
- End Select
- mciSendString StrPtr("play JofornMusic FROM 0"), 0&, 0, 0
- Do While Not IsEnd
- Sleep 50
- DoEvents
- Loop
- mciSendString StrPtr("close JofornMusic"), 0&, 0, 0
- End If
- End With
- Next I
- End If
- End Sub
- Private Function IsEnd() As Boolean
- Dim I As Long
- Dim strStatus As String
-
- strStatus = String$(256, vbNullChar)
- mciSendString StrPtr("status JofornMusic mode"), StrPtr(strStatus), 256, 0
- I = InStr(strStatus, vbNullChar)
- If I > 1 Then
- IsEnd = UCase$(Left$(strStatus, I - 1)) = "STOPPED"
- Else
- IsEnd = True
- End If
- End Function
- '从¸ô径´£¨ú¤å¥ó¦Z缀¦W
- Public Function ExtractFileExtension(ByVal strPath As String) As String
- #If VBA7 Then
- Dim ptrExt As LongPtr
- #Else
- Dim ptrExt As Long
- #End If
- Dim ExtLen As Long
-
- strPath = strPath & vbNullChar
- ptrExt = PathFindExtension(StrPtr(strPath))
- If ptrExt Then
- ExtLen = lStrLen(ptrExt)
- If ExtLen > 0 Then
- ExtractFileExtension = String(ExtLen, vbNullChar)
- CopyMemoryByPtr StrPtr(ExtractFileExtension), ptrExt, ExtLen * 2
- End If
- End If
- End Function
- Public Sub StopPlay()
- mciSendString StrPtr("close JofornMusic"), 0&, 0, 0
- End Sub
- Private Function GetShortPathName(ByVal FileName As String) As String
- Dim I As Long
- Dim strTemp As String
-
- strTemp = Space$(256)
- I = GetShortPathNameW(StrPtr(FileName), StrPtr(strTemp), 256)
- If I > 0 Then GetShortPathName = Left$(strTemp, I)
- End Function
½Æ»s¥N½X ±N즳ªº¥N½Xקאּ¡G- Public Sub macro_test2()
- Dim Bk_A As String
- Bk_A = Left(ThisWorkbook.Name, Len(ThisWorkbook.Name) - 5)
- '-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-
- Dim book_name As String
- Dim book_path As String
-
- book_name = Left(ThisWorkbook.Name, Len(ThisWorkbook.Name) - 5)
- book_path = ThisWorkbook.Path
-
- Clear
- ItemAdd ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_¦U¦ì®È«È±z¦n" & ".wav"
- ItemAdd ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_6ÂI" & ".wav"
- ItemAdd ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_¤À50" & ".wav"
- ItemAdd ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_¤À" & ".wav"
- ItemAdd ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_¶}©¹" & ".wav"
- ItemAdd ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_¥x¥_ªº" & ".wav"
- ItemAdd ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_¨®¦¸5" & ".wav"
- ItemAdd ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_¨®¦¸0" & ".wav"
- ItemAdd ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_¨®¦¸0" & ".wav"
- ItemAdd ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_¦¸" & ".wav"
- ItemAdd ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_°ªÅK" & ".wav"
- ItemAdd ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_¥_¤W" & ".wav"
- ItemAdd ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_ªº¦C¨®§Y±N¶i¯¸½Ð«e©¹" & ".wav"
- ItemAdd ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_²Ä¤G¤ë¥x" & ".wav"
- ItemAdd ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_·f¼¨Ã¯d·N¤ë¥x¶¡»ØÁÂÁÂ" & ".wav"
- StartPlay
- End Sub
½Æ»s¥N½X §¹¦¨¤W±ªº¨â¨B¾Þ§@«á¹B¦æmacro_test2´ú¸Õ¡C |
|