返回列表 上一主題 發帖

[發問] With Application.FileSearch 無法使用

[發問] With Application.FileSearch 無法使用

Dear 大大,
   之前用office 97時我都使用With Application.FileSearch找檔案
   今天用不同的office版本才發現office改版後己經不能再用了,
    請問各位前大大,以下程式碼應該怎麼修改才好?


  With Application.FileSearch
    .NewSearch
    .LookIn = FilePath
    .Filename = ".txt"
    .SearchSubFolders = False
    .Execute
   
    For i = 1 To .FoundFiles.Count
     Cells(RowIdx, 1) = FileDateTime(.FoundFiles(i))
     Cells(RowIdx, 1).Select
      FName = .FoundFiles(i)
      Cells(RowIdx, ColIdx).Select
      
      Open FName For Input As #1
       .
       .

Sub 文件()
Set file = CreateObject("scripting.filesystemobject")
For Each fils In file.getfolder("c:\").Files
Filename = Filename & fils.Name & Chr(13)
Next
MsgBox Filename
End Sub
看看这个
学习

TOP

回復 1# cw3076


    MyPath = "d:\test\"
    MyFile = Dir(MyPath & "*.Txt")
    RowIdx = 1
    Do While MyFile <> ""
        Cells(RowIdx, 1) = FileDateTime(MyPath & MyFile)
        Cells(RowIdx, 1).Select
        Open MyPath & MyFile For Input As #1
        ''
        ''
        ''
        MyFile = Dir
        RowIdx = RowIdx + 1
    Loop

TOP

感謝 wqfzqgk & GBKEE版大的指導,

   GBKEE 版大所提供的正是我想要的~~ 萬分感謝

TOP

        靜思自在 : 謊言像一朵盛開的鮮花,外表美麗,生命短暫。
返回列表 上一主題