ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   DLL Entry Points (https://www.excelbanter.com/excel-programming/339197-dll-entry-points.html)

PraxisPete

DLL Entry Points
 
Hi Everybody

I am trying to use a procedure from a dll and have used the Declare
Statement to reference to it, but I get a Run-time error €˜453: Cant find
DLL entry point.

Can anybody explain about DLL entry points?

Many thanks in advance


DM Unseen

DLL Entry Points
 
DLL entry points are the "directory listing" of a DLL. without it the
external programs cannot investigate the DLL, although programmers with
the right docs could access the functions by number(notr by name).

VBA only allows access to DLL by name. the name of the DLL function
probably is not found so maybe misspelled, or maybe the wrong DLL is
called


PraxisPete

DLL Entry Points
 
Thanks for your reply DM Unseen

This is the code used in VB6 to create the dll.

Private Sub AddinInstance_OnConnection(ByVal Application As Object, _
ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, _
ByVal AddInInst As Object, custom() As Variant)
On Error Resume Next
AddInInst.object = Me
End Sub

Private Sub AddInMsg()
MsgBox "This Message is from a dll addin"
End Sub

And this bit of code in VBA to call it

Private Declare Sub AddInMsg Lib "MySubAddIn.dll" ()

Private Sub CommandButton2_Click()
Call AddInMsg
End Sub

Any suggestions why its not found?

Many thanks


"DM Unseen" wrote:

DLL entry points are the "directory listing" of a DLL. without it the
external programs cannot investigate the DLL, although programmers with
the right docs could access the functions by number(notr by name).

VBA only allows access to DLL by name. the name of the DLL function
probably is not found so maybe misspelled, or maybe the wrong DLL is
called



DM Unseen

DLL Entry Points
 
Is this a VB dll that is actually implementing a COM/ActiveX component?

Those are not real WInAPI DLL's but ActiveX DLL's. You cannot access
them through a declare, you need to add a reference to them!

VBA editor(ALT-F11) Tools-references-browse- select dll

BTW functions need to be public in VB to be visible as methods in VBA!

DM Unseen


PraxisPete

DLL Entry Points
 
Hi DM Unseen

I am a bit out of my depth with this but trying my best. I believe that it
a VB dll implementing a COM/ActiveX component, I have tried putting the
reference as you said and change the procedure to Public, but the same error.

Want I what to do is write my procedures in VB6 and be able to write a bit
of VBA code to call them. Is there a better way I could go about it?

Many thanks


"DM Unseen" wrote:

Is this a VB dll that is actually implementing a COM/ActiveX component?

Those are not real WInAPI DLL's but ActiveX DLL's. You cannot access
them through a declare, you need to add a reference to them!

VBA editor(ALT-F11) Tools-references-browse- select dll

BTW functions need to be public in VB to be visible as methods in VBA!

DM Unseen



DM Unseen

DLL Entry Points
 
A VB COM/ActiveX component is the best option.

My guess is that you are not just creating any COM/ActiveX component,
but actually an Office COM Addin. For a COM addin you can access it
thru

Applications.Commandins("Myaddin").Object.AddInMsg


Note the declare is not required. Also realise that if you do not need
the COM callback functionality (i.e. you just want a VB library
accessible from VBA) a normal ActiveX will do.

ActveX componenets are objects within VBA just like e.g. the Office
Object library, they are Com libraries that contain objects that need
to be instantiated. After that you can access their methods(your
function) within VBA

so a VB DLL called MyactiveX needs to contain at least one object ie.
Myobject, that is creatable

Then set a reference and use the following code:

DIm newobj as new MyactiveX.Myobject

newobj.AddInMsg

There are a lot of docs on creating standard VB ActiveX components, and
that is all you need.

DM Unseen


PraxisPete

DLL Entry Points
 
Hi DM Unseen

I dont fully understand what you mean by having a creatable object in my
DLL. I have search on this and found a lot of information that supports what
you have said, but nothing that I understand enough to implement. Could you
possibly post a simple example? It would really help me out.

Many thanks


"DM Unseen" wrote:

A VB COM/ActiveX component is the best option.

My guess is that you are not just creating any COM/ActiveX component,
but actually an Office COM Addin. For a COM addin you can access it
thru

Applications.Commandins("Myaddin").Object.AddInMsg


Note the declare is not required. Also realise that if you do not need
the COM callback functionality (i.e. you just want a VB library
accessible from VBA) a normal ActiveX will do.

ActveX componenets are objects within VBA just like e.g. the Office
Object library, they are Com libraries that contain objects that need
to be instantiated. After that you can access their methods(your
function) within VBA

so a VB DLL called MyactiveX needs to contain at least one object ie.
Myobject, that is creatable

Then set a reference and use the following code:

DIm newobj as new MyactiveX.Myobject

newobj.AddInMsg

There are a lot of docs on creating standard VB ActiveX components, and
that is all you need.

DM Unseen



Nick Hebb

DLL Entry Points
 
What DM Unseen means is that it appears that you created an Add-In. The
giveaway is the AddinInstance_OnConnection(). This sub is created for
add-in's.

What you want to do is start a new project as an ActiveX DLL. If you're
unfamiliar with how to do this, no offense, but you really should buy a
decent VB6 book. It's pretty easy but there's still too much to go into
on a forum. The upside is that you can often find good used VB6 books
for cheap these days.

Quickly, though, when you wrote
Private Declare Sub AddInMsg Lib "MySubAddIn.dll" ()


This is the wrong way to set a reference to a VB DLL. This syntax is
for Win32 API DLL's (simply put, DLL's that come with Windows). For
DLL's that you create, you will want to set a reference to them in your
VBA editor by using Tools References then browse for your DLL name.

----
Nick Hebb
BreezeTree Software
http://www.breezetree.com



All times are GMT +1. The time now is 04:02 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com