我写了这段代码:
Sub Insert_Pic_From_File2(PicPath As String, ByVal row As Integer, ByVal col As Integer)
Dim Pic As Picture, Sh As Shape, Rng As Range
Set Rng = Range.Cells(row, col)
Set Rng = Rng.MergeArea
With Rng
Set Sh = ActiveSheet.Shapes.AddPicture(Filename:=PicPath, linkToFile:=msoFalse, SaveWithDocument:=msoTrue, Left:=.Left, Top:=.Top, Width:=.Width, Height:=.Height)
Sh.LockAspectRatio = msoFalse
End With
Set Sh = Nothing
Set Rng = Nothing
End Sub
我从这一行称呼它:
Insert_Pic_From_File2 ("D:\Area Open\ok.png", y, col_result)
y和col_result都是整数。
当我按Enter键时,程序给出此错误(意大利语)
编译错误: 前提:=
我用英语思考:
编译错误: 需要:=
为什么呢? 如果我删除参数y和col_result似乎没有问题,但是没有参数。
非常感谢。
答案 0 :(得分:6)
不要在参数周围使用括号!仅当您使用冗余的“ Call”语句或将函数返回值时才使用它们。
Insert_Pic_From_File2 "D:\Area Open\ok.png", y, col_result
应该没事