|
楼主 |
发表于 2023-5-30 16:51
|
显示全部楼层
附上现在正在用的VBA。
Sub 当前单元插入图片()
On Error Resume Next
Dim dress$
Set dig = Application.FileDialog(msoFileDialogFolderPicker)
With dig
.Show
dress = .SelectedItems(1) '选择文件夹地址
End With
Dim MR As Range
For Each MR In Selection
If Not IsEmpty(MR) Then
MR.Select
ML = MR.Left
MT = MR.Top
MW = MR.Width
MH = MR.Height
ActiveSheet.Shapes.AddShape(msoShapeRectangle, ML, MT, MW, MH).Select
Selection.ShapeRange.Fill.UserPicture _
dress & "\" & MR.Value & ".jpg" '设置地址所在目录下以当前单元内容为名称的.jpg图片
End If
Next
End Sub |
|