LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Pass workbook name to ActiveX DLL

First of all, ensure that the ActiveX DLL has a reference to the Excel
object library (and, for good measure, the Office library). Then, you can
use those data types in your DLL. E.g.,

[in DLL named MyDLL. class named MyClass]
Public Function GetSum(RR As Excel.Range) As Double
Dim R As Excel.Range
Dim D As Double
For Each R In RR.Cells
D = D+R.Value
Next R
GetSum = D
End Function

You would then reference MyDLL in the References dialog in VBA, and then
call the function from VBA with code like

Dim D As Double
D = MyDLL.GetSum(Range("A1:A10")

When I write ActiveX DLLs, I always prefix the non-native VB objects with
the library in which they are defined. That is, I use "As Excel.Range"
rather than "As Range". While this is not always necessary, it provides some
level of self-documentation. Moreover, it prevents potential name
collisions. For example, suppose you have a DLL that references both Excel
and Word. In both Excel and Word, there is an object named "Range", but
these are entirely different objects. By including the "Excel" library
prefix, you ensure that the compiler uses the Excel definition of a Range,
not the Word definition.

with anything more sophisticated it crashes.

In what sense does it "crash". The generic term "crash" is used to mean any
number of undesirable outcomes.

Can you provide an example procedure that you think should work but actually
"crashes"?

--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)





"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



 
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
Pass workbook name to ActiveX DLL (VB6) meldrum_scotland Excel Discussion (Misc queries) 0 August 8th 08 06:07 PM
Can I pass control to a 2nd workbook Alan Excel Programming 3 March 20th 07 01:26 PM
pass workbook on to function? Sonnich Excel Programming 1 May 18th 06 01:41 PM
pass workbook name to sub Przemek Excel Programming 1 August 11th 05 04:09 PM
Pass array of worksheets to ActiveX DLL (VB6) Hank Scorpio Excel Programming 25 June 21st 04 10:53 AM


All times are GMT +1. The time now is 10:56 AM.

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

About Us

"It's about Microsoft Excel"