禁用锁定纵横比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见下面我的答案