给定路径,打开文件,复制内容VBA

时间:2015-03-18 15:09:44

标签: vba excel-vba excel

我需要在给定路径的情况下打开文件,将内容复制到母版页的底部。任何和所有的帮助将深表感谢。我已经有一个脚本,它通过文件夹的路径并将文件路径放在一列中。

Sub CCR_Files()
Call Getfiles("C:\pathpathpath\")
End Sub

Sub Getfiles(ByVal path As String)
 'Name it
Dim fso As Object, folder As Object, subfolder As Object, file As Object

Sheets("Sheet1").Select

Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder(path)
For Each subfolder In folder.SubFolders
    Getfiles (subfolder.path)
Next subfolder
    For Each file In folder.Files
        Range("B" & Rows.Count).End(xlUp).Offset(1, 0) = file.path
        Next file

 Set fso = Nothing
 Set folder = Nothing
 Set subfolder = Nothing
 Set file = Nothing

 End Sub

有没有办法可以改变内容的路径属性?通过MSDN库进行的热门搜索没有产生太多影响。或者,有没有一种方法可以让我一步一步地读取列,打开每个文件并将内容复制/粘贴到不同工作表(同一工作簿)的底部,直到给定路径列的特殊单元格为空?非常感谢你!

0 个答案:

没有答案