|
本帖最后由 大懒猫68 于 2017-3-8 15:03 编辑
目前这个只能搜索当前文件夹符合条件的图片打印,怎么改成搜索当前及子文件夹符合条件的图片打印
最好直接帮我改下代码
Sub printpz()
Dim arr, i%, ks%, js%, ph$, TpNm$
Dim tp As Shape
ks = [j1]: js = [j2]
ph = ThisWorkbook.Path & "\"
ActiveSheet.PageSetup.PrintArea = Range("a4:c5").Address '打印区域
arr = Sheet1.UsedRange
For i = 2 To UBound(arr)
If i > js Then GoTo endpz: '条件判断
If ks > js Then MsgBox "请检查开始页是否正确"
For Each tp In Shapes '删除已有图片
If tp.Top = Range("a4:c5").Top And tp.Left = Range("a4:c5").Left Then tp.Delete
Next
If i >= ks Then
[b1] = arr(i, 1)
If Dir(ph & arr(i, 1) & ".*") <> "" Then
TpNm = Dir(ph & arr(i, 1) & ".*")
With Range("a4:c5") '插入图片
Me.Shapes.AddPicture Filename:=ph & TpNm, LinkToFile:=True, SaveWithDocument:=False, _
Left:=.Left, Top:=.Top, Width:=.Width, Height:=.Height
End With
Else
Range("a4:c5") = "无此凭证图片"
End If
ActiveSheet.PrintOut '打印
End If
Next
endpz:
MsgBox "打印完成"
End Sub
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|