|
- Function AddSheet(Str)
- Dim Sht As Worksheet
- For Each Sht In ThisWorkbook.Worksheets
- If Sht.Name = Str Then
- Set AddSheet = Sht
- Exit Function
- End If
- Next Sht
-
- Set AddSheet = Sheets.Add(After:=Worksheets(Worksheets.Count))
- AddSheet.Name = Str
- End Function
复制代码
'''
Sub SelectFolderMapToRng()
Dim Sht As Worksheet, Rng As Range, Kk
Set Rng = Selection
Set Sht = Rng.Parent
Dim Fso As FileSystemObject, oFile As File
Set Fso = New FileSystemObject
Dim oFolder As Folder
Dim Ff As FileDialog
Set Ff = Application.FileDialog(msoFileDialogFolderPicker)
With Ff
.Title = ""
.AllowMultiSelect = True
.InitialFileName = "F:"
.Show
Set oFolder = Fso.GetFolder(.SelectedItems(1))
End With
Kk = 1
For Each oFile In oFolder.Files
With Sht
Debug.Print UCase(Right(oFile.Name, 5)) = ".PPTX"
If UCase(Right(oFile.Name, 5)) = ".PPTX" Then
.Cells(Rng(Kk, 1).Row, 1) = oFile.Name
AddSheet Replace(UCase(oFile.Name), ".PPTX", "")
.Cells(Rng(Kk, 1).Row, "Z") = oFile.Path
End If
End With
Kk = Kk + 1
Next oFile
End Sub
|
|