Public Function LoadImage() As Object
For Each pics In sheetImages.Shapes
If (CStr(pics.Name) = CStr(currpartImage)) Then
Me.ImagePreview.Picture =PictureFromShape(sheetImages.Shapes(currImage))
Me.ImagePreview.PictureSizeMode = 3
currImageRow = sheetImages.Shapes(currpartImage).TopLeftCell.row + 1
End If
Next
End Function
我正在尝试让userform从我的主模块调用此函数并将其设置为形状...当此函数在userform代码中时它运行正常但我试图避免必须复制此所有我的用户形式的代码....当我把这个功能放在用户形式 - "我。" &安培; " as Object"被删除
答案 0 :(得分:0)
在例程中添加参数:
Public Sub LoadImage(imageControl as Object) As Object
For Each pics In sheetImages.Shapes
If (CStr(pics.Name) = CStr(currpartImage)) Then
imageControl .Picture =PictureFromShape(sheetImages.Shapes(currImage))
imageControl .PictureSizeMode = 3
currImageRow = sheetImages.Shapes(currpartImage).TopLeftCell.row + 1
End If
Next
End Sub
从您的表格致电:
LoadImage Me.ImagePreview
您还需要传递LoadImage
中引用但不在用户表单范围之外的任何其他项目。