相关疑难解决方法(0)

如何使用VBA在指定的单元格位置将图片插入Excel

我正在将".jpg"文件添加到我的Excel工作表中,代码如下:

'Add picture to excel
xlApp.Cells(i, 20).Select
xlApp.ActiveSheet.Pictures.Insert(picPath).Select
'Calgulate new picture size
With xlApp.Selection.ShapeRange
    .LockAspectRatio = msoTrue
    .Width = 75
    .Height = 100
End With
'Resize and make printable
With xlApp.Selection
    .Placement = 1 'xlMoveAndSize
    '.Placement = 2 'xlMove
    '.Placement = 3 'xlFreeFloating
    .PrintObject = True
End With
Run Code Online (Sandbox Code Playgroud)

我不知道我做错了什么,但它没有插入到正确的单元格中,所以我应该怎么做才能将这张图片放入Excel中的指定单元格?

excel vba image insert

24
推荐指数
3
解决办法
19万
查看次数

标签 统计

excel ×1

image ×1

insert ×1

vba ×1