将一个或多个Excel文件路径添加到选中的单元格中,
Sub SelectFile01()
定义变量
Dim l As Long
Dim x, y As Long
Dim path As String
获得当前选中单元格的行列号
' Get the location of the selected cell
x = Selection.Row()
y = Selection.Column()
'MsgBox ("conlums is " & x & "row is :" & y)
选择文件,并添加到单元格中
With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = True 'select one
.Filters.Clear 'clear
.Filters.Add "Excel Files", "*.xlsx;*.xls"
.Filters.Add "All Files", "*.*"
.Show
' put all attachments into a cell and split by ";"
For l = 1 To .SelectedItems.Count
path = path + .SelectedItems(l) + ";"
Next
Cells(x, y) = path
End With
End Sub