Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
禁用锁定纵横比VBA-Excel_Vba_Excel_Aspect Ratio - Fatal编程技术网

禁用锁定纵横比VBA-Excel

禁用锁定纵横比VBA-Excel,vba,excel,aspect-ratio,Vba,Excel,Aspect Ratio,我读过一些论坛,但似乎没有一个适合我 我正在从网上提取图片,并将它们插入我的电子表格。我希望所有这些图片的尺寸都相同 我的代码如下: 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.Loc

我读过一些论坛,但似乎没有一个适合我

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

我的代码如下:

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.ShaperAge
对象的属性,而不是
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

使用下面的代码,
LockAspectRatio
属性是
Picture.shaperage
对象的属性,而不是
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

picturehight
应该是
Picture.Height
?另外,带
块似乎是多余的。
LockAspectRatio=msoFalse
形状
对象的一个成员library@marldog请参见下面的我的答案应该
图片高度
图片高度
?另外,带
块似乎是多余的。
LockAspectRatio=msoFalse
形状
对象的一个成员library@marldog见下面我的答案