dbTalk Databases Forums  

Late binding

comp.databases.ms-access comp.databases.ms-access


Discuss Late binding in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #11  
Old   
David-W-Fenton
 
Posts: n/a

Default Re: Late binding - 09-18-2011 , 04:50 PM






"ron paii" <none (AT) nospam (DOT) com> wrote in
news:j4tef4$kog$1 (AT) dont-email (DOT) me:

Quote:

"David-W-Fenton" <NoEmail (AT) SeeSignature (DOT) invalid> wrote in message
news:Xns9F618D09F12E8f99a49ed1d0c49c5bbb2 (AT) 88 (DOT) 198.244.100...
"ron paii" <none (AT) nospam (DOT) com> wrote in
news:j4q77f$jjk$1 (AT) dont-email (DOT) me:

I have some code in A2010 that interfaces with SolidWorks EPDM
api using early binding.

Basically, you need to find the name of the component that you
need to initialize with CreateObject. You have to poke around the
registry for this. I would start by looking up the name of the
file in the early binding reference, and then search the registry
for that.

With this API New is used instead of CreateObject. I am thinking
that the application is running under Windows explorer. See my
code posted earler.
If it's a COM component, it shouldn't matter.

--
David W. Fenton http://www.dfenton.com/
contact via website only http://www.dfenton.com/DFA/

Reply With Quote
  #12  
Old   
Bob Barrows
 
Posts: n/a

Default Re: Late binding - 09-19-2011 , 10:13 AM






ron paii wrote:
Quote:
"David-W-Fenton" <NoEmail (AT) SeeSignature (DOT) invalid> wrote in message
news:Xns9F618D09F12E8f99a49ed1d0c49c5bbb2 (AT) 88 (DOT) 198.244.100...
"ron paii" <none (AT) nospam (DOT) com> wrote in
news:j4q77f$jjk$1 (AT) dont-email (DOT) me:

I have some code in A2010 that interfaces with SolidWorks EPDM api
using early binding.

Basically, you need to find the name of the component that you need
to initialize with CreateObject. You have to poke around the
registry for this. I would start by looking up the name of the file
in the early binding reference, and then search the registry for
that.


With this API New is used instead of CreateObject. I am thinking that
the application is running under Windows explorer. See my code posted
earler.
It's a COM object or else you wouldn't be able to use it in VBA. What you
need to find out is the name of the COM library containing that object.
Let's look at your code:

Quote:
Set m_Vault = New EdmVault5
So what this line of code does is instantiates a new EdmVault5 object and
points the m_Vault variable at it. Notice that you did not have to qualify
the EdmVault5 object name with the name of the COM library that contains the
object.

The reason this line of code works is that you set a reference to the
library containing this object in Tools>References. Because you did that,
you did not have to use CreateObject to instantiate it. In addition, you
were also relieved of the requirement to qualify the object name with its
library name.

If you try to create a recordset object using

Set rs=New Recordset

when you have both ADO and DAO references, you have to qualify the object
name in order not to get the "default" object, which depends on the order
the references appear in your References list. I.E., if ActiveX Data Objects
appears first, you will get an ADODB recordset. If DAO is first, you will
get a DAO recordset. In order to control which one you get, you need to
qualify the object with the name of the library.

To guarantee you get a DAO recordset, you need to use:
Set rs=New DAO.Recordset
If you want an ADO recordset you need to use
Set rs=New ADODB.Recordst

If you want to use late binding to get an ADO recordset (without setting a
reference), you have to use CreateObject (using New requires a Reference)
and you have to use the fully qualified object name when calling
CreateObject:
Set rs=CreateObject("ADODB.Recordset")

Are things becoming clearer yet? Hopefully you are beginning to realize the
need to discover the name of the library containing that EdmVault5 object. I
think the easiest way to do that is to use the Object Browser in the VBA
IDE. When you open the Object Browser (press F2 while a code window is
open), you should see a dropdown that will contain the names of all the
libraries for which you have set References (usually Access, DAO, VBA and
stdole will be listed, along with any other libraries you have Referenced).
It should be fairly simple to look at that list and figure out which one is
the EDM library. If not, type EdmVault5 into the search box and click the
search button. The search results include a column for the name of the
library containing the class (object).

Alternatively, you can search your machine's registry to discover the name
of the library, but you should not have to if you've added a Reference to
the library.

Anyways, once you have the name of the library, you should be able to
instantiate EdmVault5 using:
set m_Vault=CreateObject("<libraryname>.EdmVault5")

Reply With Quote
  #13  
Old   
ron paii
 
Posts: n/a

Default Re: Late binding - 09-19-2011 , 10:52 AM



"Bob Barrows" <reb01501 (AT) NOyahooSPAM (DOT) com> wrote

Quote:
ron paii wrote:
"David-W-Fenton" <NoEmail (AT) SeeSignature (DOT) invalid> wrote in message
news:Xns9F618D09F12E8f99a49ed1d0c49c5bbb2 (AT) 88 (DOT) 198.244.100...
"ron paii" <none (AT) nospam (DOT) com> wrote in
news:j4q77f$jjk$1 (AT) dont-email (DOT) me:

I have some code in A2010 that interfaces with SolidWorks EPDM api
using early binding.

Basically, you need to find the name of the component that you need
to initialize with CreateObject. You have to poke around the
registry for this. I would start by looking up the name of the file
in the early binding reference, and then search the registry for
that.


With this API New is used instead of CreateObject. I am thinking that
the application is running under Windows explorer. See my code posted
earler.

It's a COM object or else you wouldn't be able to use it in VBA. What you
need to find out is the name of the COM library containing that object.
Let's look at your code:

Set m_Vault = New EdmVault5

So what this line of code does is instantiates a new EdmVault5 object and
points the m_Vault variable at it. Notice that you did not have to qualify
the EdmVault5 object name with the name of the COM library that contains
the
object.

The reason this line of code works is that you set a reference to the
library containing this object in Tools>References. Because you did that,
you did not have to use CreateObject to instantiate it. In addition, you
were also relieved of the requirement to qualify the object name with its
library name.

If you try to create a recordset object using

Set rs=New Recordset

when you have both ADO and DAO references, you have to qualify the object
name in order not to get the "default" object, which depends on the order
the references appear in your References list. I.E., if ActiveX Data
Objects
appears first, you will get an ADODB recordset. If DAO is first, you will
get a DAO recordset. In order to control which one you get, you need to
qualify the object with the name of the library.

To guarantee you get a DAO recordset, you need to use:
Set rs=New DAO.Recordset
If you want an ADO recordset you need to use
Set rs=New ADODB.Recordst

If you want to use late binding to get an ADO recordset (without setting a
reference), you have to use CreateObject (using New requires a Reference)
and you have to use the fully qualified object name when calling
CreateObject:
Set rs=CreateObject("ADODB.Recordset")

Are things becoming clearer yet? Hopefully you are beginning to realize
the
need to discover the name of the library containing that EdmVault5 object.
I
think the easiest way to do that is to use the Object Browser in the VBA
IDE. When you open the Object Browser (press F2 while a code window is
open), you should see a dropdown that will contain the names of all the
libraries for which you have set References (usually Access, DAO, VBA and
stdole will be listed, along with any other libraries you have
Referenced).
It should be fairly simple to look at that list and figure out which one
is
the EDM library. If not, type EdmVault5 into the search box and click the
search button. The search results include a column for the name of the
library containing the class (object).

Alternatively, you can search your machine's registry to discover the name
of the library, but you should not have to if you've added a Reference to
the library.

Anyways, once you have the name of the library, you should be able to
instantiate EdmVault5 using:
set m_Vault=CreateObject("<libraryname>.EdmVault5")



After adding a reference to "PDMWorks Enterprise 2011 Type Library
The library name listed in Object Browser is EDMLIB

Replacing
Set m_Vault = New EdmVault5
with
Set m_Vault = CreateObject("EdmLib.EdmVault5")
results in error number 429, ActiveX component can't create object

I am thinking that because it is implemented as a file explorer add-on, I
need to automate explorer?

Reply With Quote
  #14  
Old   
Bob Barrows
 
Posts: n/a

Default Re: Late binding - 09-19-2011 , 11:56 AM



ron paii wrote:
Quote:
After adding a reference to "PDMWorks Enterprise 2011 Type Library
The library name listed in Object Browser is EDMLIB

Replacing
Set m_Vault = New EdmVault5
with
Set m_Vault = CreateObject("EdmLib.EdmVault5")
results in error number 429, ActiveX component can't create object

I am thinking that because it is implemented as a file explorer
add-on, I need to automate explorer?
In my experience, if you can use New to instantiate an object, you should be
able to use CreateObject. This is puzzling.

What happens if you try
Set m_Vault = New EdmLib.EdmVault5
? If that also fails, then that cannot be the library's name.

I suggest you try to find a forum/group devoted to that tool and ask there.

Reply With Quote
  #15  
Old   
ron paii
 
Posts: n/a

Default Re: Late binding - 09-19-2011 , 12:31 PM



"Bob Barrows" <reb01501 (AT) NOyahooSPAM (DOT) com> wrote

Quote:
ron paii wrote:
After adding a reference to "PDMWorks Enterprise 2011 Type Library
The library name listed in Object Browser is EDMLIB

Replacing
Set m_Vault = New EdmVault5
with
Set m_Vault = CreateObject("EdmLib.EdmVault5")
results in error number 429, ActiveX component can't create object

I am thinking that because it is implemented as a file explorer
add-on, I need to automate explorer?

In my experience, if you can use New to instantiate an object, you should
be
able to use CreateObject. This is puzzling.

What happens if you try
Set m_Vault = New EdmLib.EdmVault5
? If that also fails, then that cannot be the library's name.

I suggest you try to find a forum/group devoted to that tool and ask
there.




Thanks for your help

Set m_Vault = New EdmLib.EdmVault5
worked.

All the support for this API is in .NET, I had to translate it to
Access/VBA.

Reply With Quote
  #16  
Old   
Bob Barrows
 
Posts: n/a

Default Re: Late binding - 09-19-2011 , 12:55 PM



ron paii wrote:
Quote:
"Bob Barrows" <reb01501 (AT) NOyahooSPAM (DOT) com> wrote in message
news:j57se1$hcb$1 (AT) dont-email (DOT) me...
ron paii wrote:
After adding a reference to "PDMWorks Enterprise 2011 Type Library
The library name listed in Object Browser is EDMLIB

Replacing
Set m_Vault = New EdmVault5
with
Set m_Vault = CreateObject("EdmLib.EdmVault5")
results in error number 429, ActiveX component can't create object

I am thinking that because it is implemented as a file explorer
add-on, I need to automate explorer?

In my experience, if you can use New to instantiate an object, you
should be
able to use CreateObject. This is puzzling.

What happens if you try
Set m_Vault = New EdmLib.EdmVault5
? If that also fails, then that cannot be the library's name.


Set m_Vault = New EdmLib.EdmVault5
worked.

All the support for this API is in .NET, I had to translate it to
Access/VBA.
The only explanation I can come up with for this is that EdmLib depends on
another library. Adding a Reference makes that transparent so you don't need
to fully qualify it using New. Without the Reference, you need to explicitly
qualify every part of the path that gets you to EdmVault5. I would use
Object Explorer to dig into it. Perhaps SysInternals Process Explorer can
help.

Reply With Quote
  #17  
Old   
ron paii
 
Posts: n/a

Default Re: Late binding - 09-19-2011 , 02:15 PM



"Bob Barrows" <reb01501 (AT) NOyahooSPAM (DOT) com> wrote

Quote:
ron paii wrote:
"Bob Barrows" <reb01501 (AT) NOyahooSPAM (DOT) com> wrote in message
news:j57se1$hcb$1 (AT) dont-email (DOT) me...
ron paii wrote:
After adding a reference to "PDMWorks Enterprise 2011 Type Library
The library name listed in Object Browser is EDMLIB

Replacing
Set m_Vault = New EdmVault5
with
Set m_Vault = CreateObject("EdmLib.EdmVault5")
results in error number 429, ActiveX component can't create object

I am thinking that because it is implemented as a file explorer
add-on, I need to automate explorer?

In my experience, if you can use New to instantiate an object, you
should be
able to use CreateObject. This is puzzling.

What happens if you try
Set m_Vault = New EdmLib.EdmVault5
? If that also fails, then that cannot be the library's name.


Set m_Vault = New EdmLib.EdmVault5
worked.

All the support for this API is in .NET, I had to translate it to
Access/VBA.

The only explanation I can come up with for this is that EdmLib depends on
another library. Adding a Reference makes that transparent so you don't
need
to fully qualify it using New. Without the Reference, you need to
explicitly
qualify every part of the path that gets you to EdmVault5. I would use
Object Explorer to dig into it. Perhaps SysInternals Process Explorer can
help.


I didn't think of Process Explorer.

If the 1st reference of EPDM application is though explorer.exe, process
explorer creates EdmServer.exe under explorer.exe on the same level as
Access. If the 1st reference to EPDM is from Access it is under
MSAccess.exe; If I close Access EDMServer.exe is restarted on the same level
as explorer.exe. In all cases it creates 5 copies of the same dll
"EdmInterface.dll!DllUnregisterServer+0xc4188" .

Reply With Quote
  #18  
Old   
David-W-Fenton
 
Posts: n/a

Default Re: Late binding - 09-20-2011 , 04:08 PM



"ron paii" <none (AT) nospam (DOT) com> wrote in
news:j57ogm$mb4$1 (AT) dont-email (DOT) me:

Quote:
The library name listed in Object Browser is EDMLIB
I don't think that's the right name for the object.

I would search for the DLL/OLB file in the registry and see if the
name is found there. That's how I've always done this.

--
David W. Fenton http://www.dfenton.com/
contact via website only http://www.dfenton.com/DFA/

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.