Sub ad()
Dim pth As String
Dim pthname As String
Dim rng1 As Range
Dim rng2 As Range
On Error Resume Next
pth = ThisWorkbook.Path & "\" & "图片库\"
Application.ScreenUpdating = False
ActiveSheet.Unprotect '解除工作表保护
With Sheet1
Set rng1 = .Cells(2, 6)
If Len(rng1.Text) Then
Set rng2 = .Cells(8, 6)
.Pictures(rng2.Address(0, 0)).Delete
pthname = Dir(pth & rng1.Text & "*")
With ActiveSheet.Pictures.Insert(pth & pthname)
.Name = rng2.Address(0, 0)
.Height = rng2.Height
.Top = rng2.Top
.Left = rng2.Left
.Width = rng2.Width
End With
End If
End With
ActiveSheet.Protect '保护工作表
Application.ScreenUpdating = True
End Sub
Sub ad()
Dim pth As String
Dim pthname As String
Dim rng1 As Range
Dim rng2 As Range
On Error Resume Next
pth = ThisWorkbook.Path & "\" & "图片库\"
Application.ScreenUpdating = False
ActiveSheet.Unprotect '解除工作表保护
With Sheet1
Set rng1 = .Cells(2, 6)
If Len(rng1.Text) Then
Set rng2 = .Cells(8, 6)
.Pictures(rng2.Address(0, 0)).Delete
pthname = Dir(pth & rng1.Text & "*")
With ActiveSheet.Pictures.Insert(pth & pthname)
.Name = rng2.Address(0, 0)
.Height = rng2.Height
.Top = rng2.Top
.Left = rng2.Left
.Width = rng2.Width
End With
End If
End With
ActiveSheet.Protect '保护工作表
Application.ScreenUpdating = True
End Sub