【发布时间】:2023-01-20 04:52:11
【问题描述】:
我正在尝试在某个单元格范围内移动图像。
我下载它并将其添加到我指定的 Excel 工作表中。
图片看起来像这样:https://imgur.com/GteP0pM
我想调整图像大小以适应以下范围:
Set r = ws.Range("C17:O34")
看起来像这样:https://imgur.com/rddltWk
如果需要,可以手动调整图像大小,但我需要在该单元格范围内。
要选择我尝试过的图像:
Sub selectImage12()
Worksheets("T-tilbud").Shapes.Range(Array("Picture 12")).Select
End Sub
要将其移动到指定的单元格,我尝试了:
Set r = ws.Range by following this example:
Dim r As Range
Dim ws As Worksheet
Dim imagePath As String
Dim img As Picture
Set ws = Worksheets("CheckListIndustrialisation")
Set r = ws.Range("A1:D4")
imagePath = "C:\myImage.jpg"
Set img = ws.Pictures.Insert(imagePath)
With img
.ShapeRange.LockAspectRatio = msoFalse
.Top = r.Top
.Left = r.Left
.Width = r.Width
.Height = r.Height
End With
【问题讨论】: