|
Dim fh
Sub Sheet1_按钮1_Click()
Set fso = CreateObject("Scripting.FileSystemObject")
Set d = CreateObject("scripting.dictionary")
Application.ScreenUpdating = False
Application.DisplayAlerts = False
fh = ThisWorkbook.Path & "\证件合成图片\"
Sheets("程序").Select
Call Getfd(ThisWorkbook.Path & "\证件原始图片\", fso, d)
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
Sub Getfd(ByVal pth, fso, d)
Set ff = fso.getfolder(pth)
d.RemoveAll
Call del_pic
For Each f In ff.Files
If InStr(f.Name, "正面") Then
d("正面") = f
Else
If InStr(f.Name, "反面") Then
d("反面") = f
End If
End If
Next f
If d.Count = 2 Then
Call insert_pic(d("正面"), [b2])
Call insert_pic(d("反面"), [b3])
[d3].Select
y = fh & ff.Name & "\"
MkDir y
Call create_pic(y & ff.Name & ".jpg")
End If
For Each fd In ff.subfolders
Call Getfd(fd, fso, d)
Next fd
End Sub
Sub del_pic()
For Each shp In ActiveSheet.Shapes
shp.Delete
Next shp
End Sub
Sub insert_pic(f, rng)
ActiveSheet.Pictures.Insert(f).Select
With Selection
.ShapeRange.LockAspectRatio = msoFalse
.Left = rng.Left
.Top = rng.Top
.Width = rng.Width
.Height = rng.Height
End With
End Sub
Sub create_pic(fnm)
[b2:b3].CopyPicture 1, 2
ActiveSheet.Pictures.Paste.Select
With Selection
.Copy
With ActiveSheet.ChartObjects.Add(0, 0, Selection.Width, Selection.Height).Chart
.Parent.Select
.Paste
.Export fnm
.Parent.Delete
End With
.Delete
End With
End Sub
|
|