返回列表 上一主題 發帖

[發問] getFolder如何取得到第二層資料夾

[發問] getFolder如何取得到第二層資料夾

我想請問高手們,目前以下程式碼只能做到讀取一層資料夾的讀取而已,請問哪裡寫錯了嘛
我想要可以讀取我選擇好的目錄下所有的資料夾,可是不知道哪裡寫錯了
已經爬文許久,但始終無法找到答案,請高手們指點迷津,感恩
  1. Set oexcel = CreateObject("Excel.Application")
  2.     Dim objF As Object  '定義開檔物件
  3.     Dim strFoldersName As String    '定義資料夾名稱為字串型態
  4.     Dim strAllName As String   '定義所有名稱
  5.     'Dim objFs2 As Scripting.FileSystemObject
  6.    
  7.     Dim fObj2, fc2
  8.     Dim objF2 As Object
  9.    
  10.    
  11.     Dim strFolderPath As String
  12.     Dim strGetFilePath As String
  13.     strGetFilePath = File1.Path
  14.    
  15.     strFolder = Text1.Text
  16.    
  17.     Set gobjFs = CreateObject("Scripting.FileSystemObject")
  18.     Set objF = gobjFs.GetFolder(strGetFilePath)
  19.     Set fc = objF.SubFolders
  20.    
  21.     For Each F1 In fc
  22.         
  23.      
  24. 'Set oexcel = CreateObject("Excel.Application")

  25. MyPath = F1


  26. i = 0


  27. MyFile = Dir(MyPath & "\*_1.csv")  '要開啟的資料檔名


  28.                            
  29. 'g = Mid(MyFile, 1, 18)

  30.     Do While Len(MyFile) > 0
  31.    
  32.    
  33.    
  34.     Call class_NT
  35.     Application.DisplayAlerts = False  ' 關閉警告訊息
  36.    
  37.     Application.DisplayAlerts = True   ' 再打開警告訊息
  38.     i = i + 1
  39.     MyFile = Dir                                                     '下一筆
  40.     Loop
  41.     Next
複製代碼

        靜思自在 : 甘願做、歡喜受。
返回列表 上一主題