Sub Ex()
Dim Fs As Object, E, i As Integer, P, ii As Integer
With CreateObject("Scripting.FileSystemObject").GetFolder("d:\相片\") '<-修改
為你要查詢之資料夾假設在d槽
i = 1
For Each E In .SubFolders
If i > ActiveWorkbook.Sheets.Count Then
Sheets.Add(, Sheets(Sheets.Count)).Name = E.Name
Else
Sheets(i).Name = E.Name '<-新檔名取代品名以及舊檔名
End If
ii = 1
For Each P In E.Files
If InStr(UCase(P.Name), ".JPG") Then
With Sheets(i).Pictures.Insert(P)
.Top = Cells(ii, 2).Top
.Left = Cells(ii, 2).Left
.Width = 50
.Height = 50
End With
ii = ii + 5
End If
Next
i = i + 1
Next
Dim St As Worksheet: Set St = ThisWorkbook.Worksheets("Sheet1")
Dim Mx
Workbooks.Open "D:\Book2.xls"假設在檔名為Book2
Mx = Range(St.[A1], St.[C10])
Workbooks("Book2").Sheets("Sheet1").[A1].Resize(UBound(Mx, 1), UBound(Mx, 2))
= Mx
Workbooks("Book2").Close True
End With
End Sub作者: cj044 時間: 2014-7-30 14:20
目前有一堆格式相同的文件需要處理
約有1千筆 http://1drv.ms/1pi6g2x
(二. 組立步驟文字上方 是 ...
cj044 發表於 2014-7-29 14:57
可能是我描述不清楚
我重新再PO一篇文章!
軟體:Excel
版本:2007
整個原始檔案部分 http://1drv.ms/1lUW4sU
物料表檔案http://1drv.ms/1lUWdMT
規格內容需求http://1drv.ms/1qK0tGD
程式部分
Sub Ex()
Dim Fs As Object, E, i As Integer, P, ii As Integer
With CreateObject("Scripting.FileSystemObject").GetFolder("d:\相片\") '<-修改
為你要查詢之資料夾假設在d槽
i = 1
For Each E In .SubFolders
If i > ActiveWorkbook.Sheets.Count Then
Sheets.Add(, Sheets(Sheets.Count)).Name = E.Name
Else
Sheets(i).Name = E.Name '<-新檔名取代品名以及舊檔名
End If
ii = 1
For Each P In E.Files
If InStr(UCase(P.Name), ".JPG") Then
With Sheets(i).Pictures.Insert(P)
.Top = Cells(ii, 2).Top
.Left = Cells(ii, 2).Left
.Width = 50
.Height = 50
End With
ii = ii + 5
End If
Next
i = i + 1
Next
Dim St As Worksheet: Set St = ThisWorkbook.Worksheets("Sheet1")
Dim Mx
Workbooks.Open "D:\Book2.xls"假設在檔名為Book2
Mx = Range(St.[A1], St.[C10])
Workbooks("Book2").Sheets("Sheet1").[A1].Resize(UBound(Mx, 1), UBound(Mx, 2))
= Mx
Workbooks("Book2").Close True