VBA。添加单元格 - 设置开始单元格位置

时间:2016-09-22 19:04:02

标签: excel vba excel-vba

我需要这个VBA来提取所有文件名,链接它们并将它们放在A2列中并以+1为增量向下

Sub GetFileNamesInfolder()

    Dim FSO As Object
    Dim Folder As Object
    Dim File As Object
    Dim Path As String
    Dim A As Integer


    Path = "\\server5\Operations\MainBoard testing central location DO NOT REMOVE or RENAME"

    Set FSO = CreateObject("Scripting.FileSystemObject")
    Set Folder = FSO.GetFolder(Path)
    For Each File In Folder.Files
        A = A + 1
        ActiveSheet.Hyperlinks.Add Cells(A, 1), File.Path, , , File.Name
    Next
End Sub

你会怎么做?

0 个答案:

没有答案