用户输入更新/导入图像

问题描述:

我希望用户只需用按钮从他或她的计算机中选择一张图片,而无需调整大小或移动它。 而不是路径可能是“导入图像对话框”或它叫什么。 图片大小比率应该被锁定,但仍然适合宽度的页面。用户输入更新/导入图像

我试图修改这个没有任何进展。

ActiveSheet.Shapes.Range(Array("Rectangle 1")).Select With Selection.ShapeRange.Fill .Visible = msoTrue .UserPicture "C:\..." .TextureTile = msoFalse .RotateWithObject = msoTrue End With

试试这个代码

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 Sub 
+0

这是一个独立的问题,坦率地说,你问SO编写代码为您服务。你能展示你试图达到的目标吗? –