View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
NickHK NickHK is offline
external usenet poster
 
Posts: 4,391
Default How to pass active workbook to external DLL?

Mark,
This works for me:
'------------------------
'DLL <ExcelTest Class <cTest
'Reference to Excel library
Public Function GetCellA1Value(argWB As Excel.Workbook) As Variant
GetCellA1Value = argWB.Worksheets(1).Range("A1").Value
End Function
'------------------------
'In Excel
'Reference to ExcelTest.dll
Dim DLLTest As ExcelTest.cTest

Private Sub CommandButton1_Click()
Set DLLTest = New ExcelTest.cTest
With DLLTest
MsgBox "The value in cell A1 of WS(1) is " &
..GetCellA1Value(ThisWorkbook)
End With
End Sub
'------------------------

NickHK


"MarkDev" wrote in
message ...

I've changed definition of the DLL function
from Public Sub GetCellA1(locWB As Workbook)
to Public Sub GetCellA1(locWB As Excel.Workbook)
but still receving the same error message.


--
MarkDev
------------------------------------------------------------------------
MarkDev's Profile:

http://www.excelforum.com/member.php...o&userid=35572
View this thread: http://www.excelforum.com/showthread...hreadid=570387