我希望用户只需用一个按钮,就可以从他或她的计算机中选择一张图片,而不必调整大小或移动它。而不是路径,可能是一个“导入图像对话框”或它的名字。图片大小比例应锁定,但宽度仍适合页面。
我试着修改它,但没有任何进展。
ActiveSheet.Shapes.Range(Array("Rectangle 1")).Select With Selection.ShapeRange.Fill .Visible = msoTrue .UserPicture "C:\..." .TextureTile = msoFalse .RotateWithObject = msoTrue End With
发布于 2016-11-17 00:49:50
试试这段代码
Sub OpenImg()
Dim strFile
strFile = Application.GetOpenFilename(Title:="Selct an image", FileFilter:="Picture Files (*.gif;*.jpg;*.jpeg;*.bmp),*.gif;*.jpg;*.jpeg;*.bmp", MultiSelect:=False)
If strFile = False Then
MsgBox "No file selected.", vbExclamation, "Meh!"
Exit Sub
Else
ActiveSheet.Pictures.Insert(strFile).Select
With Selection.ShapeRange
.LockAspectRatio = msoTrue
.Width = ThisWorkbook.Application.Width - 75
End With
End If
End Subhttps://stackoverflow.com/questions/40635867
复制相似问题