[英]How to rotate an image in excel using vba?
Hi I'm trying to rotate an image in excel using vba, I'm using the following code: 嗨,我正在尝试使用vba在excel中旋转图像,正在使用以下代码:
Private Sub CommandButton4_Click()
Image1.ShapeRange.IncrementRotation 90
End Sub
but I don't get the expect results. 但我没有得到预期的结果。
This is how I pick the image: 这就是我选择图像的方式:
Private Sub CommandButton3_Click()
With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = True
.ButtonName = "Inserisci"
.Title = "Selezionare foto"
.Filters.Clear
.Filters.Add "JPG", "*.JPG"
.Filters.Add "JPEG File Interchange Format", "*.JPEG"
.Filters.Add "Graphics Interchange Format", "*.GIF"
.Filters.Add "Portable Network Graphics", "*.PNG"
.Filters.Add "Tag Image File Format", "*.TIFF"
.Filters.Add "All Pictures", "*.*"
If .Show = -1 Then
Image1.PictureSizeMode = fmPictureSizeModeZoom
Image1.Picture = LoadPicture(.SelectedItems(1))
Else
MsgBox ("Cancelled.")
End If
End With
End Sub 结束子
Image1 is a image in a user form. Image1是用户形式的图像。 How can I solve this?
我该如何解决?
I think you can simply remove the ShapeRange
part of it, and you should be set. 我认为您可以简单地删除其中的
ShapeRange
部分,然后进行设置。 That depends on how you declared the image object though. 这取决于您如何声明图像对象。
Here's an example: 这是一个例子:
Dim Sh As Worksheet
Dim Img As Shape
Set Sh = ActiveSheet
Set Img = Sh.Shapes(1)
Img.IncrementRotation 90
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.