|
楼主 |
发表于 2024-8-31 15:40
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
学习SelectedItems笔记
- Sub ReadPhotoInfo()
- Dim Rr, Rrr, Kk, Kkk, Str, sItem
- Rr = 10
- Rrr = Rr
- Dim Sht As Worksheet
- Dim Rng As Range, oRng As Range
- Set Rng = Selection
- Set Sht = Rng.Parent
- With Sht
- .Cells.Clear
- .Cells.Font.Size = 9
- End With
- Dim Fso As Scripting.FileSystemObject
- Set Fso = New Scripting.FileSystemObject
- Dim fDia As FileDialog
- Dim oFiles As Files, oFile As File
- Set fDia = Application.FileDialog(msoFileDialogFilePicker)
- With fDia
- .Title = ""
- .AllowMultiSelect = True
- .InitialFileName = "F:"
- .Show
-
- For Each sItem In .SelectedItems
- Set oFile = Fso.GetFile(sItem)
- If Fso.GetExtensionName(oFile.Path) = "jpg" Then
- ''Debug.Print oFile.Name, oFile.Path
- With oFile
- If InStr(.Name, "Screen") > 0 Then
- Sht.Cells(Rrr + Kkk, "Aa") = .Path
- Kkk = Kkk + 1
- Else
- Sht.Cells(Rr + Kk, "A") = .DateLastModified
- Sht.Cells(Rr + Kk, "B") = .Name
- Sht.Cells(Rr + Kk, "C") = Round(.Size / 1024 ^ 2, 1)
- Sht.Cells(Rr + Kk, "C").Select
- Sht.Cells(Rr + Kk, "C").Hyperlinks.Add Anchor:=Selection, Address:=oFile.Path, TextToDisplay:=oFile.Path
- Sht.Cells(Rr + Kk, "Z") = .Path
- With Sht
- HhMmSs .Cells(Rr, "A"), .Cells(Rr + Kk, "A")
- End With
- Kk = Kk + 1
- End If
- End With
- End If
- Next sItem
- End With
- With Sht
- Set oRng = .Cells(Rr, "C").Resize(Kk, 1)
- oRng.Select
- .Cells(1, "F") = "=" & oRng.Address
- .Cells(1, "A") = "=""Count:"" & " & " count(" & oRng.Address & ")"
- .Cells(2, "A") = "=""Sum:"" & " & " sum(" & oRng.Address & ")"
- End With
- End Sub
复制代码 |
|