View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default XLL Functions from Excel VBA

I don't see how either of your examples would work as posted. The argument
SheetName is received ByVal so even if changed in the function it would
return as originally passed. The function returns a Long but in neither
example have you assigned its result. Or does the function do something to
the sheet object.

Even if the purpose was to process SheetName and return it modified, the
app.run method would not work as variables passed as arguments are converted
to values before passing, iow they will not return modified.

Apart from the above, if anything I would have thought the application.run
method would be more likely to work than the API like Declare method. For
the Declare method to work I think, though not sure, it means the author has
included additional methods to enable the function to be called directly in
VBA. If Declare does work use it that way in preference to app.run as it
would be very significantly faster than app.run.

Regards,
Peter T

"LLT" wrote in message
...
Hi,

I am trying to call a function in an installed XLL addin in excel. Unless
I declare the function, I cannot use it.

If I use this declaration:
Declare Function EssVDisconnect Lib "ESSEXCLN.XLL" (ByVal SheetName As
Variant) As Long
and call:
EssVDisconnect "SheetName"
it works.

But if I try to use it this way (without a declaration), it doesn't work:
Application.Run "ESSEXCLN.XLL!EssVDisconnect", "SheetName"

Can someone explain if it is required for calling XLL functions from VBA
to always Declare their functions?

Thanks,

Leo