- 帖子
- 5923
- 主題
- 13
- 精華
- 1
- 積分
- 5986
- 點名
- 0
- 作業系統
- win10
- 軟體版本
- Office 2010
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台灣基隆
- 註冊時間
- 2010-5-1
- 最後登錄
- 2022-1-23
        
|
3#
發表於 2014-10-1 10:59
| 只看該作者
回復 2# hugh0620
試試看- Option Explicit
- Private Sub CommandButton1_Click()
- Dim myPath As String
- Dim K As Integer
- Dim F As Object, E As Object
- With Application.FileDialog(msoFileDialogFolderPicker)
- 'If .ButtonName = "確定" Then
- '**不管你是否按下確定鍵,或是關閉對話視窗, ** 這行程式碼都是正確的 ***'
- If .Show = True Then '有按下確定鍵
- myPath = .SelectedItems(1)
- Set F = CreateObject("Scripting.FileSystemObject").GetFolder(myPath).Files
- 'FileSystemObject 物件 有提供檔案內容的屬性可用
- If F.Count > 0 Then
- Cells.Clear
- K = 5
- Cells(K, "a") = "No"
- Cells(K, "b") = "路徑"
- Cells(K, "c") = "音檔案名稱"
- Cells(K, "d") = "檔案大小"
- Cells(K, "E") = "檔案型態"
- For Each E In F
- If E.Type = "MP3 格式聲音" Then '指定你的檔案型態: "影音檔"
- K = K + 1
- Cells(K, "a") = K - 5
- Cells(K, "b") = myPath
- Cells(K, "c") = E.Name
- Cells(K, "d") = Format(E.Size / 1024, "#,000 KB")
- Cells(K, "E") = E.Type
- End If
- Next
- End If
- End If
- End With
- End Sub
複製代碼 |
|