- 帖子
- 5923
- 主題
- 13
- 精華
- 1
- 積分
- 5986
- 點名
- 0
- 作業系統
- win10
- 軟體版本
- Office 2010
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台灣基隆
- 註冊時間
- 2010-5-1
- 最後登錄
- 2022-1-23
        
|
回復 9# whirlwind963
試試看- Option Explicit
- Sub Ex()
- Dim fs, f, e As Variant, i As Integer, xCol As Integer
- Sheets(1).Activate
- ActiveSheet.Pictures.Delete
- xCol = 3 '欄數
- Set fs = CreateObject("Scripting.FileSystemObject").GetFolder("D:\相片")
- For Each e In fs.subfolders '資料夾集合物件
- i = 2 '列數
- Cells(i, xCol) = e.Name
- For Each f In e.Files '檔案集合物件
- If UCase(Mid(f, InStr(f, ".") + 1)) = "JPG" Then
- i = i + 1
- With ActiveSheet.Pictures.Insert(f)
- .Top = Cells(i, xCol).Top
- .Left = Cells(i, xCol).Left
- .Height = 49.5
- .Width = 49.5
- Cells(i, xCol).RowHeight = .Height
- Cells(i, xCol).ColumnWidth = .Width / 5.5
- End With
- End If
- Next
- xCol = xCol + 1 '欄數
- Next
- End Sub
複製代碼 |
|