我已经阅读了几个论坛,但似乎没有一个论坛适合我。
我从网上提取图片,然后将其插入我的电子表格中。我希望所有这些图片具有相同的尺寸。
我的代码如下:
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
每次运行时,仍会检查锁定纵横比设置,图像不是我正在查找的方形格式。
非常感谢任何建议。
由于
答案 0 :(得分:1)
使用以下代码,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