Go Back   Rhinocerus > Newsgroup > Newsgroup comp.databases.ms-access

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 09-14-2011, 12:38 PM
ron paii
Guest
 
Posts: n/a
Default Late binding

I have some code in A2010 that interfaces with SolidWorks EPDM api using
early binding. Some user don't have EPDM installed so I would like to use
late binder, currently I have to maintain 2 version of the FE. The problem
is EPDM is a Windows File Explore add-on and has no separate user interface
to call using something like CreateObject("Outlook.Application"). How can I
late bind with an add-on application?

Reply With Quote
Alt Today
Advertising
 
and become member of Rhinocerus
Standard Sponsored Links

  #2 (permalink)  
Old 09-14-2011, 12:56 PM
Bob Barrows
Guest
 
Posts: n/a
Default Re: Late binding

ron paii wrote:
> I have some code in A2010 that interfaces with SolidWorks EPDM api
> using early binding. Some user don't have EPDM installed so I would
> like to use late binder, currently I have to maintain 2 version of
> the FE. The problem is EPDM is a Windows File Explore add-on and has
> no separate user interface to call using something like
> CreateObject("Outlook.Application"). How can I late bind with an
> add-on application?


A user interface is not required. For example, you can use late binding with
a DAO object:

set db=createobject("DAO.Database")





Reply With Quote
  #3 (permalink)  
Old 09-14-2011, 01:38 PM
Arvin Meyer
Guest
 
Posts: n/a
Default Re: Late binding

"ron paii" <none@nospam.com> wrote in message
news:j4q77f$jjk$1@dont-email.me...
>I have some code in A2010 that interfaces with SolidWorks EPDM api using
>early binding. Some user don't have EPDM installed so I would like to use
>late binder, currently I have to maintain 2 version of the FE. The problem
>is EPDM is a Windows File Explore add-on and has no separate user interface
>to call using something like CreateObject("Outlook.Application"). How can I
>late bind with an add-on application?



Late binding will not work if the software is not installed at all. You
cannot create a connection to software that just isn't there. The difference
between early and late binding is speed and versioning. The difference in
code is like this:

Early Binding:
' Declare the object as an early-bound object
Dim objAccess As Access.Application

Set objAccess = CreateObject("Access.Application")

' The Visible property is called
objAccess.Visible = True


Late Binding:
' Declare the object as a late-bound object
Dim objAccess As Object

Set objAccess = CreateObject("Access.Application")

' The Visible property is called
objAccess.Visible = True

--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.accessmvp.com
http://access.mvps.org
Co-author: "Access Solutions", published by Wiley


Reply With Quote
  #4 (permalink)  
Old 09-14-2011, 02:59 PM
ron paii
Guest
 
Posts: n/a
Default Re: Late binding



"Arvin Meyer" <arvinm@invalid.org> wrote in message
news:bqmdnRYmqcv9M-3TnZ2dnUVZ_qCdnZ2d@earthlink.com...
> "ron paii" <none@nospam.com> wrote in message
> news:j4q77f$jjk$1@dont-email.me...
>>I have some code in A2010 that interfaces with SolidWorks EPDM api using
>>early binding. Some user don't have EPDM installed so I would like to use
>>late binder, currently I have to maintain 2 version of the FE. The problem
>>is EPDM is a Windows File Explore add-on and has no separate user
>>interface to call using something like
>>CreateObject("Outlook.Application"). How can I late bind with an add-on
>>application?

>
>
> Late binding will not work if the software is not installed at all. You
> cannot create a connection to software that just isn't there. The
> difference between early and late binding is speed and versioning. The
> difference in code is like this:
>
> Early Binding:
> ' Declare the object as an early-bound object
> Dim objAccess As Access.Application
>
> Set objAccess = CreateObject("Access.Application")
>
> ' The Visible property is called
> objAccess.Visible = True
>
>
> Late Binding:
> ' Declare the object as a late-bound object
> Dim objAccess As Object
>
> Set objAccess = CreateObject("Access.Application")
>
> ' The Visible property is called
> objAccess.Visible = True
>
> --
> Arvin Meyer, MCP, MVP
> http://www.datastrat.com
> http://www.accessmvp.com
> http://access.mvps.org
> Co-author: "Access Solutions", published by Wiley
>


With late binding, I can check if the application is not installed and not
run the code. With early binding the FE cannot be loaded if the application
is missing.

Reply With Quote
  #5 (permalink)  
Old 09-14-2011, 08:06 PM
Tony Toews
Guest
 
Posts: n/a
Default Re: Late binding

On Wed, 14 Sep 2011 07:38:06 -0500, "ron paii" <none@nospam.com>
wrote:

>I have some code in A2010 that interfaces with SolidWorks EPDM api using
>early binding. Some user don't have EPDM installed so I would like to use
>late binder, currently I have to maintain 2 version of the FE. The problem
>is EPDM is a Windows File Explore add-on and has no separate user interface
>to call using something like CreateObject("Outlook.Application"). How can I
>late bind with an add-on application?


Can you post some sample code showing how you start using it?

Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
For a convenient utility to keep your users FEs and other files
updated see http://www.autofeupdater.com/
Reply With Quote
  #6 (permalink)  
Old 09-14-2011, 09:33 PM
ron paii
Guest
 
Posts: n/a
Default Re: Late binding



"Tony Toews" <ttoews@telusplanet.net> wrote in message
news:m9227710ts4td27kqkajuo61pu6eplvqsj@4ax.com...
> On Wed, 14 Sep 2011 07:38:06 -0500, "ron paii" <none@nospam.com>
> wrote:
>
>>I have some code in A2010 that interfaces with SolidWorks EPDM api using
>>early binding. Some user don't have EPDM installed so I would like to use
>>late binder, currently I have to maintain 2 version of the FE. The problem
>>is EPDM is a Windows File Explore add-on and has no separate user
>>interface
>>to call using something like CreateObject("Outlook.Application"). How can
>>I
>>late bind with an add-on application?

>
> Can you post some sample code showing how you start using it?
>
> Tony
> --
> Tony Toews, Microsoft Access MVP
> Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
> Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
> For a convenient utility to keep your users FEs and other files
> updated see http://www.autofeupdater.com/


This is the function I use to login to EPDM

'-------------------
' Opens the Vault and hold open in static var
' Keep ref to vault open for improved speed
'
' Return Reference to the vault
'
Private Function EPDM_GetVault() As EdmVault5

Static m_Vault As IEdmVault12

' Open vault
If m_Vault Is Nothing Then
Set m_Vault = New EdmVault5
' Loginto vault, using current user login
Call m_Vault.LoginAuto("SWVault", "None"), _
GetAccesshWnd())
Else
If Not m_Vault.IsLoggedIn Then
' Loginto vault, using current user login
Call m_Vault.LoginAuto("SWVault", "None"), GetAccesshWnd())
End If
End If

Set EPDM_GetVault = m_Vault ' Return reference to Vault
Exit Function

End Function

Reply With Quote
  #7 (permalink)  
Old 09-14-2011, 09:37 PM
ron paii
Guest
 
Posts: n/a
Default Re: Late binding



"ron paii" <none@nospam.com> wrote in message
news:j4r6jl$ipt$1@dont-email.me...
>
>
> "Tony Toews" <ttoews@telusplanet.net> wrote in message
> news:m9227710ts4td27kqkajuo61pu6eplvqsj@4ax.com...
>> On Wed, 14 Sep 2011 07:38:06 -0500, "ron paii" <none@nospam.com>
>> wrote:
>>
>>>I have some code in A2010 that interfaces with SolidWorks EPDM api using
>>>early binding. Some user don't have EPDM installed so I would like to use
>>>late binder, currently I have to maintain 2 version of the FE. The
>>>problem
>>>is EPDM is a Windows File Explore add-on and has no separate user
>>>interface
>>>to call using something like CreateObject("Outlook.Application"). How can
>>>I
>>>late bind with an add-on application?

>>
>> Can you post some sample code showing how you start using it?
>>
>> Tony
>> --
>> Tony Toews, Microsoft Access MVP
>> Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
>> Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
>> For a convenient utility to keep your users FEs and other files
>> updated see http://www.autofeupdater.com/

>
> This is the function I use to login to EPDM
>
> '-------------------
> ' Opens the Vault and hold open in static var
> ' Keep ref to vault open for improved speed
> '
> ' Return Reference to the vault
> '
> Private Function EPDM_GetVault() As EdmVault5
>
> Static m_Vault As IEdmVault12
>
> ' Open vault
> If m_Vault Is Nothing Then
> Set m_Vault = New EdmVault5
> ' Loginto vault, using current user login
> Call m_Vault.LoginAuto("SWVault", "None"), _
> GetAccesshWnd())
> Else
> If Not m_Vault.IsLoggedIn Then
> ' Loginto vault, using current user login
> Call m_Vault.LoginAuto("SWVault", "None"), GetAccesshWnd())
> End If
> End If
>
> Set EPDM_GetVault = m_Vault ' Return reference to Vault
> Exit Function
>
> End Function .


I strip out code that looks up the vault name "SWVault"

Call m_Vault.LoginAuto("SWVault", "None"), GetAccesshWnd())

should be

Call m_Vault.LoginAuto("SWVault", "None", GetAccesshWnd())


Reply With Quote
  #8 (permalink)  
Old 09-15-2011, 05:50 PM
David-W-Fenton
Guest
 
Posts: n/a
Default Re: Late binding

"Arvin Meyer" <arvinm@invalid.org> wrote in
news:bqmdnRYmqcv9M-3TnZ2dnUVZ_qCdnZ2d@earthlink.com:

> Late binding will not work if the software is not installed at
> all. You cannot create a connection to software that just isn't
> there. The difference between early and late binding is speed and
> versioning.


Well, there's also recoverability when the external component is not
installed.

I really don't think the OP thought the software would somehow
magically work if not installed but programmed through late binding
-- I think all he wanted to do was fail gracefully, since it allows
you to continue running code and tell the user it's not installed.

--
David W. Fenton http://www.dfenton.com/
contact via website only http://www.dfenton.com/DFA/
Reply With Quote
  #9 (permalink)  
Old 09-15-2011, 05:51 PM
David-W-Fenton
Guest
 
Posts: n/a
Default Re: Late binding

"ron paii" <none@nospam.com> wrote in
news:j4q77f$jjk$1@dont-email.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.

--
David W. Fenton http://www.dfenton.com/
contact via website only http://www.dfenton.com/DFA/
Reply With Quote
  #10 (permalink)  
Old 09-18-2011, 09:50 PM
David-W-Fenton
Guest
 
Posts: n/a
Default Re: Late binding

"ron paii" <none@nospam.com> wrote in
news:j4tef4$kog$1@dont-email.me:

>
>
> "David-W-Fenton" <NoEmail@SeeSignature.invalid> wrote in message
> news:Xns9F618D09F12E8f99a49ed1d0c49c5bbb2@88.198.2 44.100...
>> "ron paii" <none@nospam.com> wrote in
>> news:j4q77f$jjk$1@dont-email.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
  #11 (permalink)  
Old 09-19-2011, 03:13 PM
Bob Barrows
Guest
 
Posts: n/a
Default Re: Late binding

ron paii wrote:
> "David-W-Fenton" <NoEmail@SeeSignature.invalid> wrote in message
> news:Xns9F618D09F12E8f99a49ed1d0c49c5bbb2@88.198.2 44.100...
>> "ron paii" <none@nospam.com> wrote in
>> news:j4q77f$jjk$1@dont-email.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")



Reply With Quote
  #12 (permalink)  
Old 09-19-2011, 03:52 PM
ron paii
Guest
 
Posts: n/a
Default Re: Late binding



"Bob Barrows" <reb01501@NOyahooSPAM.com> wrote in message
news:j57m9d$6gc$1@dont-email.me...
> ron paii wrote:
>> "David-W-Fenton" <NoEmail@SeeSignature.invalid> wrote in message
>> news:Xns9F618D09F12E8f99a49ed1d0c49c5bbb2@88.198.2 44.100...
>>> "ron paii" <none@nospam.com> wrote in
>>> news:j4q77f$jjk$1@dont-email.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
  #13 (permalink)  
Old 09-19-2011, 04:56 PM
Bob Barrows
Guest
 
Posts: n/a
Default Re: Late binding

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.




Reply With Quote
  #14 (permalink)  
Old 09-19-2011, 05:31 PM
ron paii
Guest
 
Posts: n/a
Default Re: Late binding



"Bob Barrows" <reb01501@NOyahooSPAM.com> wrote in message
news:j57se1$hcb$1@dont-email.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.
>
> 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
  #15 (permalink)  
Old 09-19-2011, 07:15 PM
ron paii
Guest
 
Posts: n/a
Default Re: Late binding



"Bob Barrows" <reb01501@NOyahooSPAM.com> wrote in message
news:j57vnh$9hg$1@dont-email.me...
> ron paii wrote:
>> "Bob Barrows" <reb01501@NOyahooSPAM.com> wrote in message
>> news:j57se1$hcb$1@dont-email.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
 
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT. The time now is 08:18 PM.


Copyright ©2009

LinkBacks Enabled by vBSEO 3.3.0 RC2 © 2009, Crawlability, Inc.