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 Pass workbook name to ActiveX DLL

Ensure there's an appropriate argument in the procedure in the entry class
of your dll.

Public Function foo(objXL as Object, objWB as workbook, ByRef arg1, ByVal
arg2) as long

Now you're into the dll, call whatever you internal procedures want, passing
the object ref's of course. Remember to explicitly qualify any Excel objects
which in VBA are fine implicit, eg

objXL.ActiveWorkbook.ActiveCell

Above "As Object" assumes late binding. It'll be easier if you set a
reference in Project / References to your Excel, then declare as you would
in Excel but prefix with Excel.

Public Function foo(xlApp as Excel.Application, wb as Excel,Workbook, etc
Dim rng as Excel.Range

If you are not sure any user might have an earlier version than the one you
set a reference to, convert back to late binding before releasing.


In Excel, you could call the procedure with something like this

Dim cEntry as myAx.ClassName
Set cEntry = New myAx.ClassName

result = cEntry(application, activeworkbook, 123, "abc")


Regards,
Peter T

"meldrum_scotland" wrote in message
...
I have a VBA routine which I pass some variables to an ActiveX DLL
(VB6). I can do it with integers and longs but when I try to do it
with anything more sophisticated it crashes.

I'd like to be able to pass a the active workbook name (so the DLL
can
upon it).


Any help much appreciated.


Best


Meldrum