我想修改这段代码,所以不要在给定条件的情况下将文件夹的图像插入excel,而应该只复制路径链接(作为超链接)并将其粘贴到单元格(而不是像它一样的图片&# 39;现在正在完成)从其源文件夹。这仅仅是为了减少文件的重量。
使用实际代码:
Sub InserImage()
Dim ficimg As Variant
Dim derlig As Long
Dim i As Integer
Dim Ma_forme As Shape
Dim Maplage As Range
derlig = Range("A" & Rows.Count).End(xlUp).Row
'derlig = 10
For i = 2 To derlig
For Each Maplage In ActiveSheet.Range("B" & i)
If Ma_forme Is Nothing Then
On Error Resume Next
ficimg = "S:\Transversal projects\SAP Data\Articles\" & Range("A" & i) & "\" & Range("A" & i) & ".jpg"
nom = Range("A" & i).Value
With ActiveSheet
.Shapes.AddPicture ficimg, True, True, Left:=Range("B" & i).Left, Top:=Range("B" & i).Top, Height:=Range("B" & i).Height, Width:=Range("B" & i).Width
End With
End If
Next Maplage
Next i
End Sub