我正在尝试将用户窗体中的图像插入到Excel工作表中,但如果在我按下表单上的提交按钮时没有选择图片,则会显示运行时错误' 424':对象需要。我怎么解决这个问题? 以下是浏览按钮。
Private Sub browse_Click()
Dim pic As Variant
pic = Application.FileDialog(msoFileDialogFilePicker)
With pic
.AllowMultiSelect = False
.ButtonName = "Submit"
.Title = "Select an image file"
.Filters.Add "Image", "*.gif;*.jpg;*.jpeg", 1
If .Show = -1 Then
Me.filepath.Text = .SelectedItems(1)
Me.picpreview.PictureSizeMode = fmPictureSizeModeClip
Me.picpreview.Picture = LoadPicture(.SelectedItems(1))
Else
End If
If pic = False Then Exit Sub
End With
End Sub
以下是将图像分配给特定单元格的代码。
Cells(emptyrow, 10).Select
With xlApp.ActiveSheet.Pictures.Insert(picname) 'it is this line the debugger always points to when I submit the form without a picture
With .ShapeRange
.LockAspectRatio = msoTrue
.Height = 150
End With
.Left = xlApp.ActiveSheet.Cells(emptyrow, 10).Left
.Top = xlApp.ActiveSheet.Cells(emptyrow, 10).Top
.Placement = 1
.PrintObject = True
End With
答案 0 :(得分:0)
这应该适用于图片用户形式和插入,主要的改变是我们public interface LoginService {
@POST("auth/signin")
@FormUrlEncoded
Call<CurrentUser> signin(
@Field("email") String email,
@Field("password") String password,
@Field("device_os") String device_os,
@Field("device_identity") String device_id
);
Dim
用于Window Picker并分开选择图片和设置,而不是使用图片对象我们只需使用路径。您需要调整_Click名称。
Office.FileDialog