|
Sub pic()
Dim Shp As Shape, Rg_zp As Range, ksh As String, sht As Worksheet, Ppath As String, oldrg As Range
Set sht = Sheets("在校生档案信息")
Ppath = ThisWorkbook.Path & "\证件批量打印\"
For Each Shp In sht.Shapes
If Shp.Name Like "ksh_*" Then Shp.Delete
Next
On Error Resume Next
Set Rg_zp = sht.Cells.Find(What:="照片", After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, MatchByte:=False, SearchFormat:=False)
Set oldrg = Rg_zp
While Not Rg_zp Is Nothing
ksh = Rg_zp.Offset(17, 0).Value
With sht.Pictures.Insert(Ppath & ksh & ".jpg")
.Name = "ksh_" & ksh
.Top = Rg_zp.Top
.Left = Rg_zp.Left
.Width = Rg_zp.Width * 0.45
End With
Set Rg_zp = sht.Cells.FindNext(Rg_zp)
If Rg_zp.Address = oldrg.Address Then Exit Sub
Wend
End Sub |
|