feiyucha

效果图:

  

使用VBA:

Sub 批量插入图片()
Dim item As String \'设置一个名为cfan字符串,将其作为图片路径变量
Dim rng As Range
Sheets("Sheet4").Select \'选中要插入图片的工作表
x = [a65536].End(xlUp).Row \'取得最后一行的行号
For i = 2 To x
name = Cells(i, 2) \'从第2列(即B列)得到图片名称,并以此名查找指定位置的图片
cfan = "e:\Folder" & "\" & name & ".png" \'指定图片实际保存位置和格式
If Dir(item) <> "" Then
Cells(i, 4).Select \'图片需要插入到第4列
ActiveSheet.Pictures.Insert(item).Select
Set rng = Cells(i, 4) \'根据单元格的大小调整图片
With Selection
.Top = rng.Top + 1
.Left = rng.Left + 1
.Width = rng.Width - 1
.Height = rng.Height - 1
End With
End If
Next
End Sub

 

分类:

技术点:

相关文章:

  • 2021-12-23
  • 2021-11-30
  • 2021-12-05
  • 2021-11-11
  • 2021-12-02
  • 2021-12-21
  • 2021-11-30
  • 2022-01-02
猜你喜欢
  • 2021-12-25
  • 2021-12-02
  • 2021-12-13
  • 2021-11-20
  • 2022-02-09
  • 2022-01-06
  • 2022-01-01
相关资源
相似解决方案