DLL entry point error

OrangePeddler

New Member
Joined
Aug 21, 2012
Messages
6
I made a .DLL useing VB 2010 Express and want to call it in Excel VBA.
Here is my DLL code
Code:
[FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]Public[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]Function[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] MPSIDNum([/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] LookupType [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]Long[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2], [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] MPSValue [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2])
[/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] oConnection [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] ADODB.[/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]Connection
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] oRecordset [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] ADOR.[/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]Recordset
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] FieldCol [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]String
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]FieldCol = SetField(LookupType)
oConnection = [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] ADODB.[/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]Connection
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]oConnection.Open([/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515]"Driver={MySQL ODBC 3.51 Driver};Server=##.#.#.##;Database=my_database;User=my_username; Password=my_password;Option=3;"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2])
oRecordset = oConnection.Execute([/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515]"select "[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] & FieldCol & [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515]" from database_name where prodstatus_id = "[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] & MPSValue)
[/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] oRecordset.EOF [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]MPSIDNum = [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515]"Error: Null value"
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]Else
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]MPSIDNum = oRecordset(FieldCol)
[/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]System.[/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]Convert[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2].ToString(MPSIDNum.value)
[/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]Return[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] MPSIDNum.value
oConnection.Close()
[/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]Function
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]Public[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]Function[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] SetField([/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] Field [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]Long[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2])
[/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]Select[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] Field
[/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] 1
SetField = [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515]"order_header_WTN_IN_number"
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] 2
SetField = [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515]"order_header_WO_number"
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]Case Else
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]SetField = [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515]"Unit_dk_number"
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]Select
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]Function[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT]


Here is what my VBA code (right now its a sub I will turn it into a Function when i'm done)
Code:
[FONT=Consolas][SIZE=2][COLOR=#0000ff]Public Declare Function MPSIDNum Lib _
"C:\Documents and Settings\my_filepath\MPSData.dll" _
(ByVal LookupType As Long, ByVal MPSValue As String) As Variant
[FONT=Consolas][SIZE=2][COLOR=#0000ff]
Private Sub rundll() '(s As String, i As long)
Dim s As String: s = "156152"
Dim i As Long: i = 1
Dim rundll As String
Dim sNullString As String
sNullString = String(144, vbNullChar)
sNullString = s & sNullString
rundll = MPSIDNum(i, sNullString)
End Sub
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT]
I have a test file I made in .NET and it runs and returns the DLL data just fine but when I try this in VBA I get Run-time error '453': Can't find DLL enrty point MPSIDNum in C:\my_filepath\MPSData.dll
I been working on this every break for about a week now and can't find an answer (that I understand). I am completly selftaught on all of this/ this is my first post sorry if my post is formated incorrectly.
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Hi OrangePeddler,

In the past I've had similar problems, but defining the name a second time as an Alias has solved it:

Code:
Public Declare Function MPSIDNum Lib _
"C:\Documents and Settings\my_filepath\MPSData.dll"  _
Alias "MPSIDNum" _
(ByVal LookupType As Long, ByVal MPSValue As String) As Variant

Give this a try. I have no idea why it is sometimes necessary.

Damon
 
Upvote 0
Thanks Damon,
I tried adding an Alias with the same name and a different name then the function with no luck. Can it have anything to do with where I have the DLL saved? I left it in the "C:\...\Visual Studio 2010\Projects\MPSData\MPSData\bin\Release\MPSData.dll". That didn't bother .NET but I added the DLL as a referance not declared it as a function. I tried adding the DLL as a referance in VBA but I get a error that it can't be added as a referance.
 
Upvote 0
Hi again Orange,

I don't see anything wrong with your Declare statement. I'm sure there is no problem with the path to your DLL since the error message indicates the DLL was found, but MPSIDNum was not found within it. I suspect the problem has to do with the formation of the DLL. I have never created a DLL with VB so don't know how it does that, but assume there is an option you set to tell it to create a DLL and put MPSIDNum in it. Since most languages do not support a Variant data type, you should check VB to make sure it is capable of creating a DLL containing functions that return a Variant.
 
Upvote 0
Damon,
I found this forum DllRegisterServer entry point was not found in which StevePO suggests...

Two steps if this isn't a hard-named/certificate created DLL (i.e. for pushing into the global assembly cache):
1) Use regasm with the /tlb option, example: regasm mydll.dll /tlb:mydll.tlb
2) Push the dll into the working directory of the executable. If in design mode, this will be where the VB6.EXE is located (default is like C:\Program Files\Microsoft Visual Studio\VB98). For compiled executables, just drop it in the same directory as the executable or where you launch if you launch with a shortcut.

The above steps will go away once you've finalized the dll, hard-named/certificate and put into the global cache.

As you modify your dll/debug/test, be sure to also unregister first before re-registering so your registry doesn't get too bloated (regasm /unregister mydll.dll). You'll need to re-register/copy into the target directory each time until you make it a global assembly.
I didn't have regasm.exe that I could tell so I had to run a repare on my .NET. Now I found the regasm.exe in my v2.0.50727 file but when I go to run it I get a "Window can't find regasm" error. I'll keep working on this. Let me know if you have any other ideas that might help or even point me in the right direction.
Thanks<INPUT id=ed3258b4-04ce-4cbc-a51f-a9584ccb40a4_attachments type=hidden>
 
Upvote 0
Your dll is a managed DLL so you won't be able to use Declare. You'll have to make your VB.Net assembly COM visible and then create an instance of your class in your VBA code to be able to call its methods.
 
Last edited:
Upvote 0
Answered Re: DLL entry point error

Thanks Everyone for your help. Here is the site I used to help step me threw registering my assembly .NET - COM Interoperability in Visual Basic. I did have to enter my command as "RegAsm.exe My_DLL.dll /tlb:My_DLL.tlb /codebase" to get it to register. I'm not sure why I had to do it different then the site but it worked. <REGASM.EXE codebase TLB:MPSData.tlb MPSData.dll>

For anyone that doesn't know (/my future reference) once you successfully regester your DLL and Type Lib (TLB) go to your VBA and under Tools/References... you will find My_DLL as an option to pick. I was tring to browse for the .dll still.

I'm still getting an error when I run this but it has to do with my SQL statement so I know I'm in the dll now. As I have modified my dll from my first post I will start a new post if I can't figure it out on my own.

Thanks again to everyone this really had me stumped for some time.
 
Upvote 0
Re: Answered Re: DLL entry point error

Hello OrangePeddler
I hope you don't mind me hijacking your thread and asking some questions. I'm having almost identical problems to the ones you had and seem to have solved. i.e. I'm trying to create a DLL in VB 2010 Express which I can then use in Excel VBA. Like you I did manage to create a DLL which another VB 2010 Express project could use. I also managed to create a C++ function which I could call directly from VBA, without registering the DLL. (I used the "Declare" statement in VBA simply to point to the DLL.) But I've failed miserably at creating a DLL which I can then get VBA to see and use.
Here are my questions!
(1) Did you create a class (or set of classes) in VB 2010 Express? Or did you manage to create a function, as in you original code.
If you did manage to squeeze a function into a DLL, how did you do this? I ask this because everything I've seen seems to refer to creating a class library
(2) When compiling, did you select the "Register for COM Interop" checkbox? If so, where the heck is it! I've seen several references to needing to do this. (It seems that it should be on the compile tab but I simply can't find it.)

Have you come across this link? HOW TO: Call a Visual Basic .NET Class Library from Visual Basic for Applications in Microsoft Office
This seems to indicate that one can create a DLL in VB without having to register it.
But without me being able to select the "Register for COM Interop" checkbox, I think I'm missing something. I'm also not sure about how the hardcoded ID's interact with GUID - or if this is a problem at all.


Once again, apologies for hijacking your thread but I would be very grateful if you have any answers.

Regards
HedgePig
 
Upvote 0
Re: Answered Re: DLL entry point error

(1) Did you create a class (or set of classes) in VB 2010 Express? Or did you manage to create a function, as in you original code.
If you did manage to squeeze a function into a DLL, how did you do this? I ask this because everything I've seen seems to refer to creating a class library
(2) When compiling, did you select the "Register for COM Interop" checkbox? If so, where the heck is it! I've seen several references to needing to do this. (It seems that it should be on the compile tab but I simply can't find it.)
1: I had my function under Class Main or Class 1 whatever the default class is. The name of the function seems to be used in creating the class library. The class library is created with the TLB in
RegAsm.exe My_DLL.dll /tlb:My_DLL.tlb /codebase
2: I used the "Make Assembly COM-Visable" check box. Open your project in VB Express and go to Projects...Project_Name Properties (at the bottom). On the Application tab there is a "Assembly Information..." button that will bring up a window and that has the check box at the bottom.

After you build the project you should be able to copy and paste "RegAsm.exe" file into "Visual Studio 2010\Projects\Project_Name\Project_Name\bin\Release" the run a command prompt to the release file and run the
RegAsm.exe My_DLL.dll /tlb:My_DLL.tlb /codebase
in that. That will create the TLB(Type Library) and register the dll.
 
Upvote 0
Re: Answered Re: DLL entry point error

Thanks Everyone for your help. Here is the site I used to help step me threw registering my assembly .NET - COM Interoperability in Visual Basic. I did have to enter my command as "RegAsm.exe My_DLL.dll /tlb:My_DLL.tlb /codebase" to get it to register. I'm not sure why I had to do it different then the site but it worked. <regasm.exe MPSData.dll="" TLB:MPSData.tlb="" codebase="">

For anyone that doesn't know (/my future reference) once you successfully regester your DLL and Type Lib (TLB) go to your VBA and under Tools/References... you will find My_DLL as an option to pick. I was tring to browse for the .dll still.

I'm still getting an error when I run this but it has to do with my SQL statement so I know I'm in the dll now. As I have modified my dll from my first post I will start a new post if I can't figure it out on my own.

Thanks again to everyone this really had me stumped for some time.


I had the same issue as you had. I created the .dll with Visual Studio 2010 and created a macro file to call it by using private declare method. It does not work. And now following the steps you provided and got the dll added as a refernce under Tools -> Reference. When using it in VBA, i got error "The system cannot find the file specified" after running to "Set testingDllClass = New Testing5.Class1". Copied my simple code below. Do you have any idea where goes wrong? Would you please share your code after adding as reference?

Private testingDllClass As Testing5.Class1
Private testingDll As Testing5.Class1
Private Sub cmdClick_Click()
Set testingDllClass = New Testing5.Class1
Set testingDll = testingDllClass

End Sub

Thanks!
</regasm.exe>
 
Upvote 0

Forum statistics

Threads
1,215,214
Messages
6,123,664
Members
449,114
Latest member
aides

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top