禁用锁定纵横比 VBA - Excel

Disabling Lock Aspect Ratio VBA - Excel

我已经阅读了一些论坛,但其中 none 似乎对我有用。

我正在从网络上提取图片,然后将它们插入到我的电子表格中。我希望所有这些图片都具有相同的尺寸。

我的代码如下:

Dim img_url as string, picture as object
img_url = Range("A1")    'Some url with an img

With ActiveSheet.Pictures
   Set Picture = ActiveSheet.Pictures.Insert(img_url)
   Picture.LockAspectRatio = msoFalse
   Picture.Width = 25
   PictureHeight = 25
End With

每次我 运行 它时,锁定纵横比设置仍然被选中,图像不是我正在寻找的正方形格式。

如有任何建议,我们将不胜感激。

谢谢

使用下面的代码,LockAspectRatio 属性是 Picture.ShapeRange 对象的 属性,而不是 Picture.

Option Explicit

Sub ImageAttributes()

Dim img_url As String
Dim picture As Object

img_url = Range("A1")    'Some url with an img

With ActiveSheet
   Set picture = .Pictures.Insert(img_url)
   With picture
        With .ShapeRange
          .LockAspectRatio = msoFalse
          .Width = 25
          .Height = 25
        End With
   End With
End With


End Sub