excel怎么用图片命名批量插入图片。例如,一个文件夹里有1.2.3.1.5命 ...
发布网友
发布时间:2024-09-15 07:44
我来回答
共2个回答
热心网友
时间:2024-10-08 21:41
用VBA可以做到
上图示例的代码如下
Sub 插入图片自动调整大小()
Application.ScreenUpdating = False
Dim PN, PD As String
PD = "E:\示例图片\"
For r = 1 To 15
If r Mod 5 = 0 Then
For c = 1 To 3
PN = PD & Cells(r, c) & ".jpg"
Cells(r, c).Offset(-1, 0).Select
ActiveSheet.Pictures.Insert(PN).Select
With Selection
.ShapeRange.LockAspectRatio = msoFalse
.ShapeRange.Width = ActiveSheet.Cells(r, c).Offset(-1, 0).MergeArea.Width
.ShapeRange.Height = ActiveSheet.Cells(r, c).Offset(-1, 0).MergeArea.Height
.Placement = xlMoveAndSize
.PrintObject = True
End With
Next c
End If
Next r
[A1].Select
Application.ScreenUpdating = True
End Sub
热心网友
时间:2024-10-08 21:37
按住cril