Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to pass active workbook to external DLL?


I need to send a reference(?) to active workbook to external DLL. The
DLL is
written in VB6. In the external DLL I'll be updating this workbook.
Sample code is provided below:

Here is excel macro code:
Sub test3()
Dim TC As ClassA
Dim wbCodeBook As Workbook
Set TC = New ClassA
Set wbCodeBook = ThisWorkbook
TC.GetCellA1(wbCodeBook)
Set TC = Nothing
End Sub


Below is provided my VB6 code (this sub is part of CalssA):
Public Sub GetCellA1(locWB As Workbook)
Dim CellValue As String
CellValue = locWB.Worksheets(1).Range("A1")
MsgBox "Cell A1 = " + CellValue, "FROM DLL"
End Sub

It fails on the line TC.GetCellA1(wbCodeBook). The error message says:
"#438: Object doesn't support this property or method."

Please help


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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 415
Default How to pass active workbook to external DLL?

Your VB6 DLL does not know what a Workbook is.
However it does know Excel.Workbook, assuming you have a reference to the
Excel library, using early binding.

NickHK

"MarkDev" ¼¶¼g©ó¶l¥ó·s»D:MarkDev.2cby33_1155222915.8281@exce lforum-nospam.com...

I need to send a reference(?) to active workbook to external DLL. The
DLL is
written in VB6. In the external DLL I'll be updating this workbook.
Sample code is provided below:

Here is excel macro code:
Sub test3()
Dim TC As ClassA
Dim wbCodeBook As Workbook
Set TC = New ClassA
Set wbCodeBook = ThisWorkbook
TC.GetCellA1(wbCodeBook)
Set TC = Nothing
End Sub


Below is provided my VB6 code (this sub is part of CalssA):
Public Sub GetCellA1(locWB As Workbook)
Dim CellValue As String
CellValue = locWB.Worksheets(1).Range("A1")
MsgBox "Cell A1 = " + CellValue, "FROM DLL"
End Sub

It fails on the line TC.GetCellA1(wbCodeBook). The error message says:
"#438: Object doesn't support this property or method."

Please help


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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to pass active workbook to external DLL?


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

--
MarkDe
-----------------------------------------------------------------------
MarkDev's Profile: http://www.excelforum.com/member.php...fo&userid=3557
View this thread: http://www.excelforum.com/showthread.php?threadid=57038

  #4   Report Post  
Posted to microsoft.public.excel.programming
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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to pass active workbook to external DLL?


I had to remove brackets to make it working on my computer (?):
GetCellA1Value ThisWorkbook

Thank you Nick


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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to pass a cell as parameter for an external program? maxbell Excel Discussion (Misc queries) 1 February 8th 07 10:40 AM
Pass cell contents to external program as commandline option Research freak Excel Discussion (Misc queries) 1 September 16th 05 11:03 PM
pass workbook name to sub Przemek Excel Programming 1 August 11th 05 04:09 PM
How to read active Excel celll value by external vb application? Jack Excel Programming 2 February 11th 04 09:06 PM
Saving an external file without making it active JENNA Excel Programming 2 January 17th 04 11:51 PM


All times are GMT +1. The time now is 04:12 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"