返回列表 上一主題 發帖

如何在EXCEL 2010版 插入整個資料夾的圖片

如何在EXCEL 2010版 插入整個資料夾的圖片

各位大大:
在EXCEL 2003版 可以執行插入整個資料夾的圖片, 但在EXCEL 2010已無法執行, 要如何改寫呢? 謝謝幫忙!

Sub PictureResize()
Application.ScreenUpdating = False
Dim p As Object
Dim i%, k&, h&
With Application.FileSearch
    .LookIn = "D:\my Documents\My Pictures"  '資料夾自己設
    .FileType = msoFileTypeAllFiles
    .Filename = "*.jpg"
    .Execute

    If .Execute() > 0 Then
        For i = 1 To .FoundFiles.Count
          Set p = ActiveSheet.Pictures.Insert(.FoundFiles(i))
          p.Left = Cells(i, 1).Left
          p.Top = Cells(i, 1).Top
          p.Width = Cells(i, 1).Width
          p.Height = Cells(i, 1).RowHeight
        Next
    End If
End With
Set p = Nothing
Application.ScreenUpdating = True
End Sub

學海無涯_不恥下問

TOP

謝謝提供寶貴資料。

TOP

        靜思自在 : 有智慧才能分辨善惡邪正;有謙虛才能建立美滿人生。
返回列表 上一主題