|
本帖最后由 zjdh 于 2021-9-1 13:09 编辑
Private Sub Worksheet_Change(ByVal Target As Range)
'On Error Resume Next
Dim pth$, shp As Shape, picarr, x%, Rn As Range
If Target.Address <> "$B$2" Then Exit Sub
Set Rn = Range("C3")
For Each shp In ActiveSheet.Shapes
If Rn = shp.TopLeftCell Then
shp.Delete
End If
Next
pth = ThisWorkbook.Path & "\照片" & "\"
picarr = Array(".jpg", ".jpeg", ".bmp", ".png")
For x = 0 To UBound(picarr)
If Dir(pth & Target.Value & picarr(x)) <> "" Then
With Rn.MergeArea
ActiveSheet.Shapes.AddPicture Filename:=pth & Target.Value & picarr(x), _
LinkToFile:=msoFalse, SaveWithDocument:=msoTrue, _
Left:=.Left + 2, _
Top:=.Top + 2, _
Width:=.Width - 4, _
Height:=.Height - 4
End With
End If
Next
End Sub
|
|