返回列表 上一主題 發帖

GetOpenFilename的語法問題

回復 1# doom834
UBound(FO)-> FO 必須是陣列 ,  GetOpenFilename 方法  只傳回選取檔案名稱 沒有傳回陣列

試試看
  1. Sub Ex()
  2. Dim File_qty As Integer, SN_1 As String, i As Integer
  3. File_qty = Sheets(SN_1).Cells(2, 6)
  4. With Application.FileDialog(msoFileDialogOpen)
  5. .InitialFileName = "d:\" '指定開啟的路徑
  6. .Filters.Clear
  7. .Filters.Add "Excel File", "*.csv; *.txt; *.xls", 1
  8. .Filters.Add "*.*", "*.*", 2
  9. .FilterIndex = 1
  10. .Show
  11. If .SelectedItems.Count > File_qty Then
  12. MsgBox ("載入檔案大於" & File_qty & "個已超出程式上限,請重新選擇檔案與確認載入數量是否小於或等於" & File_qty & "個,謝謝!!")
  13. Sheets(SN_1).Select
  14. Else
  15. For i = 1 To .SelectedItems.Count
  16. MsgBox .SelectedItems(1)
  17. Next
  18. End If
  19. End With
  20. End Sub
複製代碼

TOP

        靜思自在 : 欣賞別人就是莊嚴自己。
返回列表 上一主題