Trouble call VB ActiveX dll from Excel

G

Guest

I'm having trouble calling my activex dll function from Excel.

If I use
Public Function funcR2L(strDonorSetIn As String, strRecipeIn As String) As
Variant
Dim varReturnedAns(4) As Variant
Dim intI As Integer
Dim varAns() As Variant
Dim L2R As Object

Set L2R = New lab2Recipe.VBLab2Click
varAns = L2R.funcRecipe2Lab(strDonorSetIn, strRecipeIn)

I get the error message Run-time error '5' Invalid procedure or argument.

I get the same error with
Dim L2R as lab2Recipe.VBLab2Click
Set L2R = New lab2Recipe.VBLab2Click
varAns = L2R.funcRecipe2Lab(strDonorSetIn, strRecipeIn)

I've tried using the declare statement instead, but then I get an error
stating that the entry point for the function is not found. I saw references
stating that this type of dll must be generated in 'C' but I'm not sure.

I've also tried to create an Object using:
Dim L2R As Object
L2R = CreateObject("lab2Recipe.VBLab2Click")
varAns = L2R.funcRecipe2Lab(strDonorSetIn, strRecipeIn)
Again I get the same error message.

I have set the references to my dll. I have registered my dll. My function
is in a class module called VBLab2Clik in a dll called lab2Recipe.dll defined
as:

Public Function funcRecipe2Lab(strFolderName As String, _
strClickRequest As String) As Variant()
Dim varAns(4) As Variant
Dim intI As Integer
Dim varLabEst As Variant

varLabEst = funcStrClick2Lab(strFolderName, strClickRequest)
For intI = 1 To 4
varAns(intI) = varLabEst(intI)
Next intI
funcRecipe2Lab = varAns
End Function

I used a group with additional forms to call this same function from a VB
program with no problems.

Can anyone tell me what else I need to do? Thanks.
PS, I have a subroutine defined in the class module that works from Excel
using:

Public Sub subClick2ClickList(strRecipeListIn As String, _
strDonorSetIn As String, _
strRecipeListOut As String, _
strDonorSetOut As String, _
strSpecialSetting As String)

Dim L2R As VBLab2Click
Set L2R = New VBLab2Click
L2R.subRList2RList strRecipeListIn, strDonorSetIn, _
strRecipeListOut, strDonorSetOut, strSpecialSetting
End Sub
 
G

Guest

To Whomever reads the above:

I found it! I was able to track down that input I was passing to
L2R.funcRecipe2Lab was incorrect causing it to error. It took a while. The
DLL calls were correct. To debug this, first I created simple DLL Class
Functions, called them, and returned answers to Excel. Then I modified them
to call the same internal function as the one that was failing and obtained
the error message. So I figured that the error message was from within the
function call and not the call itself. Next I stepped through the code in a
VB Group which contained the DLL and a form that let me call it. I noticed
that my input string was different, modified the input string used in Excel,
and it magically started working! I'm on my way to calling the same DLL code
from VB, Excel, and lastly an ASP.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top