Theory behind passing workbook
The error message is reporting exactly what the problem is. The variable 'D'
is declared as variant (which is what it defaults to if you don't fully
declare the variable), ie it does not match the argument in your function.
Change -
Dim D, S As Workbook
to
Dim D as Workbook, S As Workbook
Regards,
Peter T
"kris" wrote in message
...
I got when it is creating problems, but why i don't know
Function func1(ByRef S1 As Workbook)
MsgBox "hi"
End Function
Sub ff()
Dim D As Workbook
Set D = Application.Workbooks.Open("C:\practice\D.xls")
Call func1(D)
End Sub
Sub ff1()
Dim D, S As Workbook
Set D = Application.Workbooks.Open("C:\practice\D.xls")
Call func1(D)
End Sub
when I call function "Func1" using sub ff1 then i am getting the error msg
"ByRef argument type mismatch"
|