|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub delPict()
Dim sp As Shape
For Each sp In Sheet2.Shapes
If sp.Type = 11 Then
sp.Delete
End If
Next
End Sub
Sub addPict(ByVal rng As Range, pName As String)
If Dir(pName) = "" Then Exit Sub
Sheet2.Shapes.AddPicture pName, msoTrue, msoTrue, rng.Left, rng.Top, rng.Width, rng.Height
End Sub
Sub printall()
Dim arr
Dim path, pFile As String
Dim k, j, s, i As Integer
s = Sheet1.Cells(Rows.Count, 1).End(xlUp).Row
arr = Sheet1.Range("a2:i" & s).Value
k = UBound(arr, 1) '
Application.ScreenUpdating = False
path = ThisWorkbook.path & "\photo\"
For i = 1 To k - 1 Step 2
delPict
With Sheet2
.[b3].Value = arr(i, 2): .[h3] = arr(i + 1, 2)
.[b4] = arr(i, 3): .[h4] = arr(i + 1, 3)
.[b5] = arr(i, 4): .[h5] = arr(i + 1, 4)
.[b6] = arr(i, 5): .[h6] = arr(i + 1, 5)
.[b7] = arr(i, 6): .[h7] = arr(i + 1, 6)
.[d7] = arr(i, 7): .[j7] = arr(i + 1, 7)
.[b8] = arr(i, 8): .[h8] = arr(i + 1, 8)
.[b9] = arr(i, 9): .[h9] = arr(i + 1, 9)
pFile = path & arr(i, 5) & ".png"
addPict .Range("e3:e8"), pFile
pFile = path & arr(i + 1, 5) & ".png"
addPict .Range("k3:k8"), pFile
.PrintPreview
End With
Next
If k Mod 2 = 1 Then
delPict
With Sheet2
i = k
.[b3].Value = arr(i, 2): .[h3] = ""
.[b4] = arr(i, 3): .[h4] = ""
.[b5] = arr(i, 4): .[h5] = ""
.[b6] = arr(i, 5): .[h6] = ""
.[b7] = arr(i, 6): .[h7] = ""
.[d7] = arr(i, 7): .[j7] = ""
.[b8] = arr(i, 8): .[h8] = ""
.[b9] = arr(i, 9): .[h9] = ""
pFile = path & arr(i, 5) & ".png" ‘照片格式不一样改这就可以’
addPict .Range("e3:e8"), pFile
.PrintOut 1, 1, 1
End With
End If
Application.ScreenUpdating = False
End Sub
|
评分
-
1
查看全部评分
-
|