View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.vb.general.discussion
Gale Green Gale Green is offline
external usenet poster
 
Posts: 4
Default Pass array of worksheets to ActiveX DLL (VB6)


Hi.

I compiled the dummy dll without any problem, then opened an Excel
2002 workbook, set a reference to the dll, and included the following
in a standard module:


If I understand the above correctly, you are calling TestDLLVersion
from a standard module in an Excel 2002 workbook. Is that right?

It is quite correct that, when automating Office products from VB, you
should early bind:

Dim MyXL As Excel.Application
Set MyXL = New .Excel.Application
or
Set MyXL = CreateObject("Excel.Application")

On your development machine, you should have, and set a reference to,
the earliest version of the Office product that you want your app to
work with.

However, that is Automation from VB. Passing a parameter from another
version of Excel, I suspect, is a different kettle of fish.
TestDLLVersion's arguments are probably being set up to expect an
Excel 8 object, hence the failure when passing in a Workbook reference
from Excel 2002.

You could try declaring TestDLLVersion's arguments as Object instead
of Excel.Worksheet.

You can still use early binding within the Sub:

Dim MySheet As Excel.Worksheet
Set MySheet = TargetWorksheets(n)
....
Set MySheet = Nothing

You may get a more useful response from an Excel newsgroup.

Gale.