excel宏以获取特定文件夹修改中文件的链接列表



我有一个宏,允许用户选择一个文件夹,并将该文件夹中的文件列为链接。但是,该列表从单元格A1开始,但是说我单击了单元格i5,希望列表从我单击的单元格开始。如何修改以下宏:

Sub GetFileNames()
Dim xFSO As Object
Dim xFolder As Object
Dim xFile As Object
Dim xFiDialog As FileDialog
Dim xPath As String
Dim I As Integer
Set xFiDialog = Application.FileDialog(msoFileDialogFolderPicker)
If xFiDialog.Show = -1 Then
    xPath = xFiDialog.SelectedItems(1)
End If
Set xFiDialog = Nothing
If xPath = "" Then Exit Sub
Set xFSO = CreateObject("Scripting.FileSystemObject")
Set xFolder = xFSO.GetFolder(xPath)
For Each xFile In xFolder.Files
    I = I + 1
    ActiveSheet.Hyperlinks.Add Cells(I, 1), xFile.Path, , , xFile.Name
Next
End Sub

非常感谢您的专业知识!!!!

feather将其输入到您的宏:

Dim curCell As Range
Set curCell = ActiveCell
i = 0
For Each xFile In xFolder.Files
    ActiveSheet.Hyperlinks.Add Cells(curCell.Row + i, curCell.Column), xFile.Path, , , xFile.Name
    i = i + 1
Next

运行宏时,它将查看活动单元格是什么,然后使用该列和行开始。