ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Error: 424 Object required (https://www.excelbanter.com/excel-programming/320709-error-424-object-required.html)

DavidM[_3_]

Error: 424 Object required
 
Hi

Can anybody explain the following to me

I have a com dll with a class Object that has a function setParam.
When I call from VBA

Object.setParam(X) gives me Error: 424 Object required

But
Object.setParam X
and
call Object.setParam(X)

both work

and if X is a Double instead of some object the first call above works

I'd really like to understand what is the issue. (Even if I have the fix)

Thanks in advance

Tom Ogilvy

Error: 424 Object required
 
Because that is the syntax of VBE. You don't put the arguments in
parentheses unless you use the call. If you do, then the argument is
evaluated before it is passed - in your case, you are returning the default
value of X as the argument to SetParam so your object gets dereferenced or
it can't be evaluated perhaps. If X is a double, then it is evaluated, but
that doesn't change what X is - so no problem in that case.

--
Regards,
Tom Ogilvy

"DavidM" wrote in message
om...
Hi

Can anybody explain the following to me

I have a com dll with a class Object that has a function setParam.
When I call from VBA

Object.setParam(X) gives me Error: 424 Object required

But
Object.setParam X
and
call Object.setParam(X)

both work

and if X is a Double instead of some object the first call above works

I'd really like to understand what is the issue. (Even if I have the fix)

Thanks in advance





All times are GMT +1. The time now is 11:45 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com