Sen a pointer to function to external DLL from VBA (Excel 97)

How can I send a pointer to a function (developed in my excel 97 workbook, in VBA) to an external function in a DLL? The function pointed to by the pointer will follow the rules of parameter needed.
Do you know if it's possible, and if I must care about the parameter passing, erc?

Please, send a simple example. Thanks a lot
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I don't know if it is yet a feature of VBA, but VB has a keyword, "AddressOf", which is used for exactly that - to create a pointer to a procedure in order to pass it in an API call.

Check your VBA Help files to see if "AddressOf" appears.  If so, it will probably even have an example that's relevant.  If not, if VBA doesn't have this, then it's going to be very difficult to do what you want.

mquilesAuthor Commented:
Unfortunately, it doen't work in VBA. Thanks for your help
VBA does not support SubClassing. You could write a Dll in VB and call that from your VBA mod
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

mquilesAuthor Commented:
But, how can I give the address of the fucntion in the VB DLL, to a C DLL?
inside your dll you would use this line:

if the name of your function is

MyFunction(Anything as Long) as Long

then you would get the address like this:

Lx = Addressof(MyFunction)

you could also include it in your enum api call like this

hwnd& = me.hwnd
retval& = 0

EnumWindows(hWnd&, Addressof(Myfunction), retval&)


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mquilesAuthor Commented:
Ok, it works! Thanks for your help
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.