返回列表 上一主題 發帖

[發問] 從某資料夾中,將檔案名稱建立在excel中

[發問] 從某資料夾中,將檔案名稱建立在excel中

Dear 大大

          有無辦法將某個資料夾中的影音檔(副檔名:.wmv或任何副檔名)名稱,
          1.每一個影音檔的名稱都建立在excel中  
             (如果可以,是否一個欄位寫檔案名稱、一個欄位寫上副檔名稱[ex:excel 就填上excel、word就填上word])
          2.每個名稱建立超連結

         
學習才能提升自己

本帖最後由 hugh0620 於 2014-9-30 13:45 編輯

Dear 大大
             附件是我初稿,有設定類似指定資料夾,在抓取該資料夾中的檔案名稱,但發生了問題
    能-檔案名稱匯入-HH-20140930-001.rar (13.27 KB)
            下面是我的程式碼
            在第13列  myFileName = Dir(myPath, 0) 抓到的是"",所以,跑不出來
  1. Option Explicit
  2. Private Sub CommandButton1_Click()

  3. Dim myPath As String
  4. Dim myFileName As String
  5. Dim i As Long
  6. Dim K As Integer

  7. With Application.FileDialog(msoFileDialogFolderPicker)
  8.      .Show
  9.   If .ButtonName = "確定" Then
  10.     myPath = .SelectedItems(1)
  11.     myFileName = Dir(myPath, 0)
  12.     Do While Len(myFileName) > 0
  13.       Debug.Print myPath & myFileName
  14.       sheet1.Range("B65536").End(xlUp).Offset(1, 0) = myPath        '路徑
  15.       sheet1.Range("C65536").End(xlUp).Offset(1, 0) = myFileName    '檔名
  16.       K = K + 1
  17.       sheet1.Range("A65536").End(xlUp).Offset(1, 0) = K             'No
  18.       myFileName = Dir()
  19.     Loop
  20.   End If
  21. End With


  22. End Sub
複製代碼
學習才能提升自己

TOP

        靜思自在 : 是非當教育,讚美作警惕。
返回列表 上一主題